Remove unused MSVC files
Now that CMake compiles these dependencies directly, there's no need to keep pre-built libraries around, except for MSVC2003.
This commit is contained in:
parent
079681a9d7
commit
75af33b7ed
335 changed files with 148 additions and 29832 deletions
14
.gitignore
vendored
14
.gitignore
vendored
|
@ -7,16 +7,18 @@
|
|||
*.rec
|
||||
build.7z
|
||||
build.zip
|
||||
msvc2003/devilution/orig.asm
|
||||
msvc2003/devilution/compare.asm
|
||||
|
||||
# Executables
|
||||
build_en/*.exe
|
||||
build_jp/*.exe
|
||||
|
||||
# MSVC trash
|
||||
msvc/msvc2003/CSE2.ncb
|
||||
msvc/msvc2003/CSE2.suo
|
||||
msvc/msvc2003/Debug
|
||||
msvc/msvc2003/Release
|
||||
msvc/msvc2003/Debug (Japanese)
|
||||
msvc/msvc2003/Release (Japanese)
|
||||
msvc2003/CSE2.ncb
|
||||
msvc2003/CSE2.suo
|
||||
msvc2003/Debug
|
||||
msvc2003/Release
|
||||
msvc2003/Debug (Japanese)
|
||||
msvc2003/Release (Japanese)
|
||||
*.aps
|
||||
|
|
|
@ -57,7 +57,7 @@ Run 'make' in the base directory, preferably with some of the following settings
|
|||
|
||||
### Visual Studio .NET 2003
|
||||
|
||||
Project files for Visual Studio .NET 2003 are available in the 'msvc/msvc2003' directory.
|
||||
Project files for Visual Studio .NET 2003 are available in the 'msvc2003' directory.
|
||||
|
||||
Visual Studio .NET 2003 was used by Pixel to create the original `Doukutsu.exe`, so these project files allow us to check the accuracy of the decompilation by comparing the generated assembly code to that of the original executable.
|
||||
|
||||
|
|
|
@ -1,417 +0,0 @@
|
|||
Android
|
||||
================================================================================
|
||||
|
||||
Matt Styles wrote a tutorial on building SDL for Android with Visual Studio:
|
||||
http://trederia.blogspot.de/2017/03/building-sdl2-for-android-with-visual.html
|
||||
|
||||
The rest of this README covers the Android gradle style build process.
|
||||
|
||||
If you are using the older ant build process, it is no longer officially
|
||||
supported, but you can use the "android-project-ant" directory as a template.
|
||||
|
||||
|
||||
================================================================================
|
||||
Requirements
|
||||
================================================================================
|
||||
|
||||
Android SDK (version 26 or later)
|
||||
https://developer.android.com/sdk/index.html
|
||||
|
||||
Android NDK r15c or later
|
||||
https://developer.android.com/tools/sdk/ndk/index.html
|
||||
|
||||
Minimum API level supported by SDL: 14 (Android 4.0.1)
|
||||
|
||||
|
||||
================================================================================
|
||||
How the port works
|
||||
================================================================================
|
||||
|
||||
- Android applications are Java-based, optionally with parts written in C
|
||||
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
|
||||
the SDL library
|
||||
- This means that your application C code must be placed inside an Android
|
||||
Java project, along with some C support code that communicates with Java
|
||||
- This eventually produces a standard Android .apk package
|
||||
|
||||
The Android Java code implements an "Activity" and can be found in:
|
||||
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
|
||||
|
||||
The Java code loads your game code, the SDL shared library, and
|
||||
dispatches to native functions implemented in the SDL library:
|
||||
src/core/android/SDL_android.c
|
||||
|
||||
|
||||
================================================================================
|
||||
Building an app
|
||||
================================================================================
|
||||
|
||||
For simple projects you can use the script located at build-scripts/androidbuild.sh
|
||||
|
||||
There's two ways of using it:
|
||||
|
||||
androidbuild.sh com.yourcompany.yourapp < sources.list
|
||||
androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c
|
||||
|
||||
sources.list should be a text file with a source file name in each line
|
||||
Filenames should be specified relative to the current directory, for example if
|
||||
you are in the build-scripts directory and want to create the testgles.c test, you'll
|
||||
run:
|
||||
|
||||
./androidbuild.sh org.libsdl.testgles ../test/testgles.c
|
||||
|
||||
One limitation of this script is that all sources provided will be aggregated into
|
||||
a single directory, thus all your source files should have a unique name.
|
||||
|
||||
Once the project is complete the script will tell you where the debug APK is located.
|
||||
If you want to create a signed release APK, you can use the project created by this
|
||||
utility to generate it.
|
||||
|
||||
Finally, a word of caution: re running androidbuild.sh wipes any changes you may have
|
||||
done in the build directory for the app!
|
||||
|
||||
|
||||
For more complex projects, follow these instructions:
|
||||
|
||||
1. Copy the android-project directory wherever you want to keep your projects
|
||||
and rename it to the name of your project.
|
||||
2. Move or symlink this SDL directory into the "<project>/app/jni" directory
|
||||
3. Edit "<project>/app/jni/src/Android.mk" to include your source files
|
||||
|
||||
4a. If you want to use Android Studio, simply open your <project> directory and start building.
|
||||
|
||||
4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
|
||||
|
||||
Here's an explanation of the files in the Android project, so you can customize them:
|
||||
|
||||
android-project/app
|
||||
build.gradle - build info including the application version and SDK
|
||||
src/main/AndroidManifest.xml - package manifest. Among others, it contains the class name of the main Activity and the package name of the application.
|
||||
jni/ - directory holding native code
|
||||
jni/Application.mk - Application JNI settings, including target platform and STL library
|
||||
jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories
|
||||
jni/SDL/ - (symlink to) directory holding the SDL library files
|
||||
jni/SDL/Android.mk - Android makefile for creating the SDL shared library
|
||||
jni/src/ - directory holding your C/C++ source
|
||||
jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references
|
||||
src/main/assets/ - directory holding asset files for your application
|
||||
src/main/res/ - directory holding resources for your application
|
||||
src/main/res/mipmap-* - directories holding icons for different phone hardware
|
||||
src/main/res/values/strings.xml - strings used in your application, including the application name
|
||||
src/main/java/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation. You should instead subclass this for your application.
|
||||
|
||||
|
||||
================================================================================
|
||||
Customizing your application name
|
||||
================================================================================
|
||||
|
||||
To customize your application name, edit AndroidManifest.xml and replace
|
||||
"org.libsdl.app" with an identifier for your product package.
|
||||
|
||||
Then create a Java class extending SDLActivity and place it in a directory
|
||||
under src matching your package, e.g.
|
||||
|
||||
src/com/gamemaker/game/MyGame.java
|
||||
|
||||
Here's an example of a minimal class file:
|
||||
|
||||
--- MyGame.java --------------------------
|
||||
package com.gamemaker.game;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
/**
|
||||
* A sample wrapper class that just calls SDLActivity
|
||||
*/
|
||||
|
||||
public class MyGame extends SDLActivity { }
|
||||
|
||||
------------------------------------------
|
||||
|
||||
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
|
||||
class, .e.g. "MyGame"
|
||||
|
||||
|
||||
================================================================================
|
||||
Customizing your application icon
|
||||
================================================================================
|
||||
|
||||
Conceptually changing your icon is just replacing the "ic_launcher.png" files in
|
||||
the drawable directories under the res directory. There are several directories
|
||||
for different screen sizes.
|
||||
|
||||
|
||||
================================================================================
|
||||
Loading assets
|
||||
================================================================================
|
||||
|
||||
Any files you put in the "app/src/main/assets" directory of your project
|
||||
directory will get bundled into the application package and you can load
|
||||
them using the standard functions in SDL_rwops.h.
|
||||
|
||||
There are also a few Android specific functions that allow you to get other
|
||||
useful paths for saving and loading data:
|
||||
* SDL_AndroidGetInternalStoragePath()
|
||||
* SDL_AndroidGetExternalStorageState()
|
||||
* SDL_AndroidGetExternalStoragePath()
|
||||
|
||||
See SDL_system.h for more details on these functions.
|
||||
|
||||
The asset packaging system will, by default, compress certain file extensions.
|
||||
SDL includes two asset file access mechanisms, the preferred one is the so
|
||||
called "File Descriptor" method, which is faster and doesn't involve the Dalvik
|
||||
GC, but given this method does not work on compressed assets, there is also the
|
||||
"Input Stream" method, which is automatically used as a fall back by SDL. You
|
||||
may want to keep this fact in mind when building your APK, specially when large
|
||||
files are involved.
|
||||
For more information on which extensions get compressed by default and how to
|
||||
disable this behaviour, see for example:
|
||||
|
||||
http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/
|
||||
|
||||
|
||||
================================================================================
|
||||
Pause / Resume behaviour
|
||||
================================================================================
|
||||
|
||||
If SDL is compiled with SDL_ANDROID_BLOCK_ON_PAUSE defined (the default),
|
||||
the event loop will block itself when the app is paused (ie, when the user
|
||||
returns to the main Android dashboard). Blocking is better in terms of battery
|
||||
use, and it allows your app to spring back to life instantaneously after resume
|
||||
(versus polling for a resume message).
|
||||
|
||||
Upon resume, SDL will attempt to restore the GL context automatically.
|
||||
In modern devices (Android 3.0 and up) this will most likely succeed and your
|
||||
app can continue to operate as it was.
|
||||
|
||||
However, there's a chance (on older hardware, or on systems under heavy load),
|
||||
where the GL context can not be restored. In that case you have to listen for
|
||||
a specific message, (which is not yet implemented!) and restore your textures
|
||||
manually or quit the app (which is actually the kind of behaviour you'll see
|
||||
under iOS, if the OS can not restore your GL context it will just kill your app)
|
||||
|
||||
|
||||
================================================================================
|
||||
Threads and the Java VM
|
||||
================================================================================
|
||||
|
||||
For a quick tour on how Linux native threads interoperate with the Java VM, take
|
||||
a look here: https://developer.android.com/guide/practices/jni.html
|
||||
|
||||
If you want to use threads in your SDL app, it's strongly recommended that you
|
||||
do so by creating them using SDL functions. This way, the required attach/detach
|
||||
handling is managed by SDL automagically. If you have threads created by other
|
||||
means and they make calls to SDL functions, make sure that you call
|
||||
Android_JNI_SetupThread() before doing anything else otherwise SDL will attach
|
||||
your thread automatically anyway (when you make an SDL call), but it'll never
|
||||
detach it.
|
||||
|
||||
|
||||
================================================================================
|
||||
Using STL
|
||||
================================================================================
|
||||
|
||||
You can use STL in your project by creating an Application.mk file in the jni
|
||||
folder and adding the following line:
|
||||
|
||||
APP_STL := c++_shared
|
||||
|
||||
For more information go here:
|
||||
https://developer.android.com/ndk/guides/cpp-support
|
||||
|
||||
|
||||
================================================================================
|
||||
Using the emulator
|
||||
================================================================================
|
||||
|
||||
There are some good tips and tricks for getting the most out of the
|
||||
emulator here: https://developer.android.com/tools/devices/emulator.html
|
||||
|
||||
Especially useful is the info on setting up OpenGL ES 2.0 emulation.
|
||||
|
||||
Notice that this software emulator is incredibly slow and needs a lot of disk space.
|
||||
Using a real device works better.
|
||||
|
||||
|
||||
================================================================================
|
||||
Troubleshooting
|
||||
================================================================================
|
||||
|
||||
You can see if adb can see any devices with the following command:
|
||||
|
||||
adb devices
|
||||
|
||||
You can see the output of log messages on the default device with:
|
||||
|
||||
adb logcat
|
||||
|
||||
You can push files to the device with:
|
||||
|
||||
adb push local_file remote_path_and_file
|
||||
|
||||
You can push files to the SD Card at /sdcard, for example:
|
||||
|
||||
adb push moose.dat /sdcard/moose.dat
|
||||
|
||||
You can see the files on the SD card with a shell command:
|
||||
|
||||
adb shell ls /sdcard/
|
||||
|
||||
You can start a command shell on the default device with:
|
||||
|
||||
adb shell
|
||||
|
||||
You can remove the library files of your project (and not the SDL lib files) with:
|
||||
|
||||
ndk-build clean
|
||||
|
||||
You can do a build with the following command:
|
||||
|
||||
ndk-build
|
||||
|
||||
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
|
||||
|
||||
ndk-build V=1
|
||||
|
||||
If your application crashes in native code, you can use ndk-stack to get a symbolic stack trace:
|
||||
https://developer.android.com/ndk/guides/ndk-stack
|
||||
|
||||
If you want to go through the process manually, you can use addr2line to convert the
|
||||
addresses in the stack trace to lines in your code.
|
||||
|
||||
For example, if your crash looks like this:
|
||||
|
||||
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
|
||||
I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4
|
||||
I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c
|
||||
I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c
|
||||
I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030
|
||||
I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
|
||||
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
|
||||
|
||||
You can see that there's a crash in the C library being called from the main code.
|
||||
I run addr2line with the debug version of my code:
|
||||
|
||||
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
|
||||
|
||||
and then paste in the number after "pc" in the call stack, from the line that I care about:
|
||||
000014bc
|
||||
|
||||
I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23.
|
||||
|
||||
You can add logging to your code to help show what's happening:
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
|
||||
|
||||
If you need to build without optimization turned on, you can create a file called
|
||||
"Application.mk" in the jni directory, with the following line in it:
|
||||
|
||||
APP_OPTIM := debug
|
||||
|
||||
|
||||
================================================================================
|
||||
Memory debugging
|
||||
================================================================================
|
||||
|
||||
The best (and slowest) way to debug memory issues on Android is valgrind.
|
||||
Valgrind has support for Android out of the box, just grab code using:
|
||||
|
||||
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
|
||||
|
||||
... and follow the instructions in the file README.android to build it.
|
||||
|
||||
One thing I needed to do on Mac OS X was change the path to the toolchain,
|
||||
and add ranlib to the environment variables:
|
||||
export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-ranlib
|
||||
|
||||
Once valgrind is built, you can create a wrapper script to launch your
|
||||
application with it, changing org.libsdl.app to your package identifier:
|
||||
|
||||
--- start_valgrind_app -------------------
|
||||
#!/system/bin/sh
|
||||
export TMPDIR=/data/data/org.libsdl.app
|
||||
exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
|
||||
------------------------------------------
|
||||
|
||||
Then push it to the device:
|
||||
|
||||
adb push start_valgrind_app /data/local
|
||||
|
||||
and make it executable:
|
||||
|
||||
adb shell chmod 755 /data/local/start_valgrind_app
|
||||
|
||||
and tell Android to use the script to launch your application:
|
||||
|
||||
adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
|
||||
|
||||
If the setprop command says "could not set property", it's likely that
|
||||
your package name is too long and you should make it shorter by changing
|
||||
AndroidManifest.xml and the path to your class file in android-project/src
|
||||
|
||||
You can then launch your application normally and waaaaaaaiiittt for it.
|
||||
You can monitor the startup process with the logcat command above, and
|
||||
when it's done (or even while it's running) you can grab the valgrind
|
||||
output file:
|
||||
|
||||
adb pull /sdcard/valgrind.log
|
||||
|
||||
When you're done instrumenting with valgrind, you can disable the wrapper:
|
||||
|
||||
adb shell setprop wrap.org.libsdl.app ""
|
||||
|
||||
|
||||
================================================================================
|
||||
Graphics debugging
|
||||
================================================================================
|
||||
|
||||
If you are developing on a compatible Tegra-based tablet, NVidia provides
|
||||
Tegra Graphics Debugger at their website. Because SDL2 dynamically loads EGL
|
||||
and GLES libraries, you must follow their instructions for installing the
|
||||
interposer library on a rooted device. The non-rooted instructions are not
|
||||
compatible with applications that use SDL2 for video.
|
||||
|
||||
The Tegra Graphics Debugger is available from NVidia here:
|
||||
https://developer.nvidia.com/tegra-graphics-debugger
|
||||
|
||||
|
||||
================================================================================
|
||||
Why is API level 14 the minimum required?
|
||||
================================================================================
|
||||
|
||||
The latest NDK toolchain doesn't support targeting earlier than API level 14.
|
||||
As of this writing, according to https://developer.android.com/about/dashboards/index.html
|
||||
about 99% of the Android devices accessing Google Play support API level 14 or
|
||||
higher (October 2017).
|
||||
|
||||
|
||||
================================================================================
|
||||
A note regarding the use of the "dirty rectangles" rendering technique
|
||||
================================================================================
|
||||
|
||||
If your app uses a variation of the "dirty rectangles" rendering technique,
|
||||
where you only update a portion of the screen on each frame, you may notice a
|
||||
variety of visual glitches on Android, that are not present on other platforms.
|
||||
This is caused by SDL's use of EGL as the support system to handle OpenGL ES/ES2
|
||||
contexts, in particular the use of the eglSwapBuffers function. As stated in the
|
||||
documentation for the function "The contents of ancillary buffers are always
|
||||
undefined after calling eglSwapBuffers".
|
||||
Setting the EGL_SWAP_BEHAVIOR attribute of the surface to EGL_BUFFER_PRESERVED
|
||||
is not possible for SDL as it requires EGL 1.4, available only on the API level
|
||||
17+, so the only workaround available on this platform is to redraw the entire
|
||||
screen each frame.
|
||||
|
||||
Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
|
||||
|
||||
|
||||
================================================================================
|
||||
Known issues
|
||||
================================================================================
|
||||
|
||||
- The number of buttons reported for each joystick is hardcoded to be 36, which
|
||||
is the current maximum number of buttons Android can report.
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
CMake
|
||||
================================================================================
|
||||
(www.cmake.org)
|
||||
|
||||
SDL's build system was traditionally based on autotools. Over time, this
|
||||
approach has suffered from several issues across the different supported
|
||||
platforms.
|
||||
To solve these problems, a new build system based on CMake is under development.
|
||||
It works in parallel to the legacy system, so users can experiment with it
|
||||
without complication.
|
||||
While still experimental, the build system should be usable on the following
|
||||
platforms:
|
||||
|
||||
* FreeBSD
|
||||
* Linux
|
||||
* VS.NET 2010
|
||||
* MinGW and Msys
|
||||
* OS X with support for XCode
|
||||
|
||||
|
||||
================================================================================
|
||||
Usage
|
||||
================================================================================
|
||||
|
||||
Assuming the source for SDL is located at ~/sdl
|
||||
|
||||
cd ~
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ../sdl
|
||||
|
||||
This will build the static and dynamic versions of SDL in the ~/build directory.
|
|
@ -1,107 +0,0 @@
|
|||
DirectFB
|
||||
========
|
||||
|
||||
Supports:
|
||||
|
||||
- Hardware YUV overlays
|
||||
- OpenGL - software only
|
||||
- 2D/3D accelerations (depends on directfb driver)
|
||||
- multiple displays
|
||||
- windows
|
||||
|
||||
What you need:
|
||||
|
||||
* DirectFB 1.0.1, 1.2.x, 1.3.0
|
||||
* Kernel-Framebuffer support: required: vesafb, radeonfb ....
|
||||
* Mesa 7.0.x - optional for OpenGL
|
||||
|
||||
/etc/directfbrc
|
||||
|
||||
This file should contain the following lines to make
|
||||
your joystick work and avoid crashes:
|
||||
------------------------
|
||||
disable-module=joystick
|
||||
disable-module=cle266
|
||||
disable-module=cyber5k
|
||||
no-linux-input-grab
|
||||
------------------------
|
||||
|
||||
To disable to use x11 backend when DISPLAY variable is found use
|
||||
|
||||
export SDL_DIRECTFB_X11_CHECK=0
|
||||
|
||||
To disable the use of linux input devices, i.e. multimice/multikeyboard support,
|
||||
use
|
||||
|
||||
export SDL_DIRECTFB_LINUX_INPUT=0
|
||||
|
||||
To use hardware accelerated YUV-overlays for YUV-textures, use:
|
||||
|
||||
export SDL_DIRECTFB_YUV_DIRECT=1
|
||||
|
||||
This is disabled by default. It will only support one
|
||||
YUV texture, namely the first. Every other YUV texture will be
|
||||
rendered in software.
|
||||
|
||||
In addition, you may use (directfb-1.2.x)
|
||||
|
||||
export SDL_DIRECTFB_YUV_UNDERLAY=1
|
||||
|
||||
to make the YUV texture an underlay. This will make the cursor to
|
||||
be shown.
|
||||
|
||||
Simple Window Manager
|
||||
=====================
|
||||
|
||||
The driver has support for a very, very basic window manager you may
|
||||
want to use when running with "wm=default". Use
|
||||
|
||||
export SDL_DIRECTFB_WM=1
|
||||
|
||||
to enable basic window borders. In order to have the window title rendered,
|
||||
you need to have the following font installed:
|
||||
|
||||
/usr/share/fonts/truetype/freefont/FreeSans.ttf
|
||||
|
||||
OpenGL Support
|
||||
==============
|
||||
|
||||
The following instructions will give you *software* OpenGL. However this
|
||||
works at least on all directfb supported platforms.
|
||||
|
||||
As of this writing 20100802 you need to pull Mesa from git and do the following:
|
||||
|
||||
------------------------
|
||||
git clone git://anongit.freedesktop.org/git/mesa/mesa
|
||||
cd mesa
|
||||
git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
|
||||
------------------------
|
||||
|
||||
Edit configs/linux-directfb so that the Directories-section looks like
|
||||
------------------------
|
||||
# Directories
|
||||
SRC_DIRS = mesa glu
|
||||
GLU_DIRS = sgi
|
||||
DRIVER_DIRS = directfb
|
||||
PROGRAM_DIRS =
|
||||
------------------------
|
||||
|
||||
make linux-directfb
|
||||
make
|
||||
|
||||
echo Installing - please enter sudo pw.
|
||||
|
||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||
cd src/mesa/drivers/directfb
|
||||
make
|
||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||
------------------------
|
||||
|
||||
To run the SDL - testprograms:
|
||||
|
||||
export SDL_VIDEODRIVER=directfb
|
||||
export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib
|
||||
export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7
|
||||
|
||||
./testgl
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
Dynamic API
|
||||
================================================================================
|
||||
Originally posted by Ryan at:
|
||||
https://plus.google.com/103391075724026391227/posts/TB8UfnDYu4U
|
||||
|
||||
Background:
|
||||
|
||||
- The Steam Runtime has (at least in theory) a really kick-ass build of SDL2,
|
||||
but developers are shipping their own SDL2 with individual Steam games.
|
||||
These games might stop getting updates, but a newer SDL2 might be needed later.
|
||||
Certainly we'll always be fixing bugs in SDL, even if a new video target isn't
|
||||
ever needed, and these fixes won't make it to a game shipping its own SDL.
|
||||
- Even if we replace the SDL2 in those games with a compatible one, that is to
|
||||
say, edit a developer's Steam depot (yuck!), there are developers that are
|
||||
statically linking SDL2 that we can't do this for. We can't even force the
|
||||
dynamic loader to ignore their SDL2 in this case, of course.
|
||||
- If you don't ship an SDL2 with the game in some form, people that disabled the
|
||||
Steam Runtime, or just tried to run the game from the command line instead of
|
||||
Steam might find themselves unable to run the game, due to a missing dependency.
|
||||
- If you want to ship on non-Steam platforms like GOG or Humble Bundle, or target
|
||||
generic Linux boxes that may or may not have SDL2 installed, you have to ship
|
||||
the library or risk a total failure to launch. So now, you might have to have
|
||||
a non-Steam build plus a Steam build (that is, one with and one without SDL2
|
||||
included), which is inconvenient if you could have had one universal build
|
||||
that works everywhere.
|
||||
- We like the zlib license, but the biggest complaint from the open source
|
||||
community about the license change is the static linking. The LGPL forced this
|
||||
as a legal, not technical issue, but zlib doesn't care. Even those that aren't
|
||||
concerned about the GNU freedoms found themselves solving the same problems:
|
||||
swapping in a newer SDL to an older game often times can save the day.
|
||||
Static linking stops this dead.
|
||||
|
||||
So here's what we did:
|
||||
|
||||
SDL now has, internally, a table of function pointers. So, this is what SDL_Init
|
||||
now looks like:
|
||||
|
||||
UInt32 SDL_Init(Uint32 flags)
|
||||
{
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
|
||||
Except that is all done with a bunch of macro magic so we don't have to maintain
|
||||
every one of these.
|
||||
|
||||
What is jump_table.SDL_init()? Eventually, that's a function pointer of the real
|
||||
SDL_Init() that you've been calling all this time. But at startup, it looks more
|
||||
like this:
|
||||
|
||||
Uint32 SDL_Init_DEFAULT(Uint32 flags)
|
||||
{
|
||||
SDL_InitDynamicAPI();
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
|
||||
SDL_InitDynamicAPI() fills in jump_table with all the actual SDL function
|
||||
pointers, which means that this _DEFAULT function never gets called again.
|
||||
First call to any SDL function sets the whole thing up.
|
||||
|
||||
So you might be asking, what was the value in that? Isn't this what the operating
|
||||
system's dynamic loader was supposed to do for us? Yes, but now we've got this
|
||||
level of indirection, we can do things like this:
|
||||
|
||||
export SDL_DYNAMIC_API=/my/actual/libSDL-2.0.so.0
|
||||
./MyGameThatIsStaticallyLinkedToSDL2
|
||||
|
||||
And now, this game that is statically linked to SDL, can still be overridden
|
||||
with a newer, or better, SDL. The statically linked one will only be used as
|
||||
far as calling into the jump table in this case. But in cases where no override
|
||||
is desired, the statically linked version will provide its own jump table,
|
||||
and everyone is happy.
|
||||
|
||||
So now:
|
||||
- Developers can statically link SDL, and users can still replace it.
|
||||
(We'd still rather you ship a shared library, though!)
|
||||
- Developers can ship an SDL with their game, Valve can override it for, say,
|
||||
new features on SteamOS, or distros can override it for their own needs,
|
||||
but it'll also just work in the default case.
|
||||
- Developers can ship the same package to everyone (Humble Bundle, GOG, etc),
|
||||
and it'll do the right thing.
|
||||
- End users (and Valve) can update a game's SDL in almost any case,
|
||||
to keep abandoned games running on newer platforms.
|
||||
- Everyone develops with SDL exactly as they have been doing all along.
|
||||
Same headers, same ABI. Just get the latest version to enable this magic.
|
||||
|
||||
|
||||
A little more about SDL_InitDynamicAPI():
|
||||
|
||||
Internally, InitAPI does some locking to make sure everything waits until a
|
||||
single thread initializes everything (although even SDL_CreateThread() goes
|
||||
through here before spinning a thread, too), and then decides if it should use
|
||||
an external SDL library. If not, it sets up the jump table using the current
|
||||
SDL's function pointers (which might be statically linked into a program, or in
|
||||
a shared library of its own). If so, it loads that library and looks for and
|
||||
calls a single function:
|
||||
|
||||
SInt32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize);
|
||||
|
||||
That function takes a version number (more on that in a moment), the address of
|
||||
the jump table, and the size, in bytes, of the table.
|
||||
Now, we've got policy here: this table's layout never changes; new stuff gets
|
||||
added to the end. Therefore SDL_DYNAPI_entry() knows that it can provide all
|
||||
the needed functions if tablesize <= sizeof its own jump table. If tablesize is
|
||||
bigger (say, SDL 2.0.4 is trying to load SDL 2.0.3), then we know to abort, but
|
||||
if it's smaller, we know we can provide the entire API that the caller needs.
|
||||
|
||||
The version variable is a failsafe switch.
|
||||
Right now it's always 1. This number changes when there are major API changes
|
||||
(so we know if the tablesize might be smaller, or entries in it have changed).
|
||||
Right now SDL_DYNAPI_entry gives up if the version doesn't match, but it's not
|
||||
inconceivable to have a small dispatch library that only supplies this one
|
||||
function and loads different, otherwise-incompatible SDL libraries and has the
|
||||
right one initialize the jump table based on the version. For something that
|
||||
must generically catch lots of different versions of SDL over time, like the
|
||||
Steam Client, this isn't a bad option.
|
||||
|
||||
Finally, I'm sure some people are reading this and thinking,
|
||||
"I don't want that overhead in my project!"
|
||||
To which I would point out that the extra function call through the jump table
|
||||
probably wouldn't even show up in a profile, but lucky you: this can all be
|
||||
disabled. You can build SDL without this if you absolutely must, but we would
|
||||
encourage you not to do that. However, on heavily locked down platforms like
|
||||
iOS, or maybe when debugging, it makes sense to disable it. The way this is
|
||||
designed in SDL, you just have to change one #define, and the entire system
|
||||
vaporizes out, and SDL functions exactly like it always did. Most of it is
|
||||
macro magic, so the system is contained to one C file and a few headers.
|
||||
However, this is on by default and you have to edit a header file to turn it
|
||||
off. Our hopes is that if we make it easy to disable, but not too easy,
|
||||
everyone will ultimately be able to get what they want, but we've gently
|
||||
nudged everyone towards what we think is the best solution.
|
|
@ -1,35 +0,0 @@
|
|||
Emscripten
|
||||
================================================================================
|
||||
|
||||
Build:
|
||||
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ emconfigure ../configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-O2"
|
||||
$ emmake make
|
||||
|
||||
Or with cmake:
|
||||
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ emcmake cmake ..
|
||||
$ emmake make
|
||||
|
||||
To build one of the tests:
|
||||
|
||||
$ cd test/
|
||||
$ emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html
|
||||
|
||||
Uses GLES2 renderer or software
|
||||
|
||||
Some other SDL2 libraries can be easily built (assuming SDL2 is installed somewhere):
|
||||
|
||||
SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/):
|
||||
|
||||
$ EMCONFIGURE_JS=1 emconfigure ../configure
|
||||
build as usual...
|
||||
|
||||
SDL_gfx (http://cms.ferzkopp.net/index.php/software/13-sdl-gfx):
|
||||
|
||||
$ EMCONFIGURE_JS=1 emconfigure ../configure --disable-mmx
|
||||
build as usual...
|
|
@ -1,71 +0,0 @@
|
|||
Dollar Gestures
|
||||
===========================================================================
|
||||
SDL provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
|
||||
|
||||
Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up.
|
||||
|
||||
Dollar gestures are assigned an Id based on a hash function. This is guaranteed to remain constant for a given gesture. There is a (small) chance that two different gestures will be assigned the same ID. In this case, simply re-recording one of the gestures should result in a different ID.
|
||||
|
||||
Recording:
|
||||
----------
|
||||
To begin recording on a touch device call:
|
||||
SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch device you wish to record on, or -1 to record on all connected devices.
|
||||
|
||||
Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
|
||||
A SDL_DOLLARRECORD event is a dgesture with the following fields:
|
||||
|
||||
* event.dgesture.touchId - the Id of the touch used to record the gesture.
|
||||
* event.dgesture.gestureId - the unique id of the recorded gesture.
|
||||
|
||||
|
||||
Performing:
|
||||
-----------
|
||||
As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
|
||||
|
||||
* event.dgesture.touchId - the Id of the touch which performed the gesture.
|
||||
* event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke.
|
||||
* event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
|
||||
* event.dgesture.numFingers - the number of fingers used to draw the stroke.
|
||||
|
||||
Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
|
||||
|
||||
|
||||
|
||||
Saving:
|
||||
-------
|
||||
To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
Both functions return the number of gestures successfully saved.
|
||||
|
||||
|
||||
Loading:
|
||||
--------
|
||||
To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file.
|
||||
|
||||
SDL_LoadDollarTemplates returns the number of templates successfully loaded.
|
||||
|
||||
|
||||
|
||||
===========================================================================
|
||||
Multi Gestures
|
||||
===========================================================================
|
||||
SDL provides simple support for pinch/rotate/swipe gestures.
|
||||
Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
|
||||
|
||||
* event.mgesture.touchId - the Id of the touch on which the gesture was performed.
|
||||
* event.mgesture.x - the normalized x coordinate of the gesture. (0..1)
|
||||
* event.mgesture.y - the normalized y coordinate of the gesture. (0..1)
|
||||
* event.mgesture.dTheta - the amount that the fingers rotated during this motion.
|
||||
* event.mgesture.dDist - the amount that the fingers pinched during this motion.
|
||||
* event.mgesture.numFingers - the number of fingers used in the gesture.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
|
@ -1,22 +0,0 @@
|
|||
Mercurial
|
||||
=========
|
||||
|
||||
The latest development version of SDL is available via Mercurial.
|
||||
Mercurial allows you to get up-to-the-minute fixes and enhancements;
|
||||
as a developer works on a source tree, you can use "hg" to mirror that
|
||||
source tree instead of waiting for an official release. Please look
|
||||
at the Mercurial website ( https://www.mercurial-scm.org/ ) for more
|
||||
information on using hg, where you can also download software for
|
||||
Mac OS X, Windows, and Unix systems.
|
||||
|
||||
hg clone http://hg.libsdl.org/SDL
|
||||
|
||||
If you are building SDL via configure, you will need to run autogen.sh
|
||||
before running configure.
|
||||
|
||||
There is a web interface to the subversion repository at:
|
||||
http://hg.libsdl.org/SDL/
|
||||
|
||||
There is an RSS feed available at that URL, for those that want to
|
||||
track commits in real time.
|
||||
|
|
@ -1,284 +0,0 @@
|
|||
iOS
|
||||
======
|
||||
|
||||
==============================================================================
|
||||
Building the Simple DirectMedia Layer for iOS 5.1+
|
||||
==============================================================================
|
||||
|
||||
Requirements: Mac OS X 10.8 or later and the iOS 7+ SDK.
|
||||
|
||||
Instructions:
|
||||
|
||||
1. Open SDL.xcodeproj (located in Xcode-iOS/SDL) in Xcode.
|
||||
2. Select your desired target, and hit build.
|
||||
|
||||
There are three build targets:
|
||||
- libSDL.a:
|
||||
Build SDL as a statically linked library
|
||||
- testsdl:
|
||||
Build a test program (there are known test failures which are fine)
|
||||
- Template:
|
||||
Package a project template together with the SDL for iPhone static libraries and copies of the SDL headers. The template includes proper references to the SDL library and headers, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen.
|
||||
|
||||
|
||||
==============================================================================
|
||||
Build SDL for iOS from the command line
|
||||
==============================================================================
|
||||
|
||||
1. cd (PATH WHERE THE SDL CODE IS)/build-scripts
|
||||
2. ./iosbuild.sh
|
||||
|
||||
If everything goes fine, you should see a build/ios directory, inside there's
|
||||
two directories "lib" and "include".
|
||||
"include" contains a copy of the SDL headers that you'll need for your project,
|
||||
make sure to configure XCode to look for headers there.
|
||||
"lib" contains find two files, libSDL2.a and libSDL2main.a, you have to add both
|
||||
to your XCode project. These libraries contain three architectures in them,
|
||||
armv6 for legacy devices, armv7, and i386 (for the simulator).
|
||||
By default, iosbuild.sh will autodetect the SDK version you have installed using
|
||||
xcodebuild -showsdks, and build for iOS >= 3.0, you can override this behaviour
|
||||
by setting the MIN_OS_VERSION variable, ie:
|
||||
|
||||
MIN_OS_VERSION=4.2 ./iosbuild.sh
|
||||
|
||||
==============================================================================
|
||||
Using the Simple DirectMedia Layer for iOS
|
||||
==============================================================================
|
||||
|
||||
FIXME: This needs to be updated for the latest methods
|
||||
|
||||
Here is the easiest method:
|
||||
1. Build the SDL library (libSDL2.a) and the iPhone SDL Application template.
|
||||
2. Install the iPhone SDL Application template by copying it to one of Xcode's template directories. I recommend creating a directory called "SDL" in "/Developer/Platforms/iOS.platform/Developer/Library/Xcode/Project Templates/" and placing it there.
|
||||
3. Start a new project using the template. The project should be immediately ready for use with SDL.
|
||||
|
||||
Here is a more manual method:
|
||||
1. Create a new iOS view based application.
|
||||
2. Build the SDL static library (libSDL2.a) for iOS and include them in your project. Xcode will ignore the library that is not currently of the correct architecture, hence your app will work both on iOS and in the iOS Simulator.
|
||||
3. Include the SDL header files in your project.
|
||||
4. Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iOS provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iOS produces its user interface programmatically.
|
||||
5. Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell Xcode not to use the project prefix file, as it includes Objective-C code.
|
||||
|
||||
==============================================================================
|
||||
Notes -- Retina / High-DPI and window sizes
|
||||
==============================================================================
|
||||
|
||||
Window and display mode sizes in SDL are in "screen coordinates" (or "points",
|
||||
in Apple's terminology) rather than in pixels. On iOS this means that a window
|
||||
created on an iPhone 6 will have a size in screen coordinates of 375 x 667,
|
||||
rather than a size in pixels of 750 x 1334. All iOS apps are expected to
|
||||
size their content based on screen coordinates / points rather than pixels,
|
||||
as this allows different iOS devices to have different pixel densities
|
||||
(Retina versus non-Retina screens, etc.) without apps caring too much.
|
||||
|
||||
By default SDL will not use the full pixel density of the screen on
|
||||
Retina/high-dpi capable devices. Use the SDL_WINDOW_ALLOW_HIGHDPI flag when
|
||||
creating your window to enable high-dpi support.
|
||||
|
||||
When high-dpi support is enabled, SDL_GetWindowSize() and display mode sizes
|
||||
will still be in "screen coordinates" rather than pixels, but the window will
|
||||
have a much greater pixel density when the device supports it, and the
|
||||
SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() functions (depending on
|
||||
whether raw OpenGL or the SDL_Render API is used) can be queried to determine
|
||||
the size in pixels of the drawable screen framebuffer.
|
||||
|
||||
Some OpenGL ES functions such as glViewport expect sizes in pixels rather than
|
||||
sizes in screen coordinates. When doing 2D rendering with OpenGL ES, an
|
||||
orthographic projection matrix using the size in screen coordinates
|
||||
(SDL_GetWindowSize()) can be used in order to display content at the same scale
|
||||
no matter whether a Retina device is used or not.
|
||||
|
||||
==============================================================================
|
||||
Notes -- Application events
|
||||
==============================================================================
|
||||
|
||||
On iOS the application goes through a fixed life cycle and you will get
|
||||
notifications of state changes via application events. When these events
|
||||
are delivered you must handle them in an event callback because the OS may
|
||||
not give you any processing time after the events are delivered.
|
||||
|
||||
e.g.
|
||||
|
||||
int HandleAppEvents(void *userdata, SDL_Event *event)
|
||||
{
|
||||
switch (event->type)
|
||||
{
|
||||
case SDL_APP_TERMINATING:
|
||||
/* Terminate the app.
|
||||
Shut everything down before returning from this function.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_LOWMEMORY:
|
||||
/* You will get this when your app is paused and iOS wants more memory.
|
||||
Release as much memory as possible.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_WILLENTERBACKGROUND:
|
||||
/* Prepare your app to go into the background. Stop loops, etc.
|
||||
This gets called when the user hits the home button, or gets a call.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_DIDENTERBACKGROUND:
|
||||
/* This will get called if the user accepted whatever sent your app to the background.
|
||||
If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
|
||||
When you get this, you have 5 seconds to save all your state or the app will be terminated.
|
||||
Your app is NOT active at this point.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_WILLENTERFOREGROUND:
|
||||
/* This call happens when your app is coming back to the foreground.
|
||||
Restore all your state here.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_DIDENTERFOREGROUND:
|
||||
/* Restart your loops here.
|
||||
Your app is interactive and getting CPU again.
|
||||
*/
|
||||
return 0;
|
||||
default:
|
||||
/* No special processing, add it to the event queue */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_SetEventFilter(HandleAppEvents, NULL);
|
||||
|
||||
... run your main loop
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
==============================================================================
|
||||
Notes -- Accelerometer as Joystick
|
||||
==============================================================================
|
||||
|
||||
SDL for iPhone supports polling the built in accelerometer as a joystick device. For an example on how to do this, see the accelerometer.c in the demos directory.
|
||||
|
||||
The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_JoystickGetAxis() reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_JoystickGetAxis() reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
|
||||
|
||||
==============================================================================
|
||||
Notes -- OpenGL ES
|
||||
==============================================================================
|
||||
|
||||
Your SDL application for iOS uses OpenGL ES for video by default.
|
||||
|
||||
OpenGL ES for iOS supports several display pixel formats, such as RGBA8 and RGB565, which provide a 32 bit and 16 bit color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8 by setting each color component to 8 bits in SDL_GL_SetAttribute().
|
||||
|
||||
If your application doesn't use OpenGL's depth buffer, you may find significant performance improvement by setting SDL_GL_DEPTH_SIZE to 0.
|
||||
|
||||
Finally, if your application completely redraws the screen each frame, you may find significant performance improvement by setting the attribute SDL_GL_RETAINED_BACKING to 0.
|
||||
|
||||
OpenGL ES on iOS doesn't use the traditional system-framebuffer setup provided in other operating systems. Special care must be taken because of this:
|
||||
|
||||
- The drawable Renderbuffer must be bound to the GL_RENDERBUFFER binding point when SDL_GL_SwapWindow() is called.
|
||||
- The drawable Framebuffer Object must be bound while rendering to the screen and when SDL_GL_SwapWindow() is called.
|
||||
- If multisample antialiasing (MSAA) is used and glReadPixels is used on the screen, the drawable framebuffer must be resolved to the MSAA resolve framebuffer (via glBlitFramebuffer or glResolveMultisampleFramebufferAPPLE), and the MSAA resolve framebuffer must be bound to the GL_READ_FRAMEBUFFER binding point, before glReadPixels is called.
|
||||
|
||||
The above objects can be obtained via SDL_GetWindowWMInfo() (in SDL_syswm.h).
|
||||
|
||||
==============================================================================
|
||||
Notes -- Keyboard
|
||||
==============================================================================
|
||||
|
||||
The SDL keyboard API has been extended to support on-screen keyboards:
|
||||
|
||||
void SDL_StartTextInput()
|
||||
-- enables text events and reveals the onscreen keyboard.
|
||||
|
||||
void SDL_StopTextInput()
|
||||
-- disables text events and hides the onscreen keyboard.
|
||||
|
||||
SDL_bool SDL_IsTextInputActive()
|
||||
-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
|
||||
|
||||
|
||||
==============================================================================
|
||||
Notes -- Reading and Writing files
|
||||
==============================================================================
|
||||
|
||||
Each application installed on iPhone resides in a sandbox which includes its own Application Home directory. Your application may not access files outside this directory.
|
||||
|
||||
Once your application is installed its directory tree looks like:
|
||||
|
||||
MySDLApp Home/
|
||||
MySDLApp.app
|
||||
Documents/
|
||||
Library/
|
||||
Preferences/
|
||||
tmp/
|
||||
|
||||
When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".
|
||||
|
||||
More information on this subject is available here:
|
||||
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
|
||||
|
||||
==============================================================================
|
||||
Notes -- iPhone SDL limitations
|
||||
==============================================================================
|
||||
|
||||
Windows:
|
||||
Full-size, single window applications only. You cannot create multi-window SDL applications for iPhone OS. The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow() the flag SDL_WINDOW_BORDERLESS).
|
||||
|
||||
Textures:
|
||||
The optimal texture formats on iOS are SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, and SDL_PIXELFORMAT_RGB24 pixel formats.
|
||||
|
||||
Loading Shared Objects:
|
||||
This is disabled by default since it seems to break the terms of the iOS SDK agreement for iOS versions prior to iOS 8. It can be re-enabled in SDL_config_iphoneos.h.
|
||||
|
||||
==============================================================================
|
||||
Game Center
|
||||
==============================================================================
|
||||
|
||||
Game Center integration might require that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
|
||||
|
||||
int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
|
||||
|
||||
This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
|
||||
|
||||
e.g.
|
||||
|
||||
extern "C"
|
||||
void ShowFrame(void*)
|
||||
{
|
||||
... do event handling, frame logic and rendering ...
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
... initialize game ...
|
||||
|
||||
#if __IPHONEOS__
|
||||
// Initialize the Game Center for scoring and matchmaking
|
||||
InitGameCenter();
|
||||
|
||||
// Set up the game to run in the window animation callback on iOS
|
||||
// so that Game Center and so forth works correctly.
|
||||
SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
|
||||
#else
|
||||
while ( running ) {
|
||||
ShowFrame(0);
|
||||
DelayFrame();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
==============================================================================
|
||||
Deploying to older versions of iOS
|
||||
==============================================================================
|
||||
|
||||
SDL supports deploying to older versions of iOS than are supported by the latest version of Xcode, all the way back to iOS 6.1
|
||||
|
||||
In order to do that you need to download an older version of Xcode:
|
||||
https://developer.apple.com/download/more/?name=Xcode
|
||||
|
||||
Open the package contents of the older Xcode and your newer version of Xcode and copy over the folders in Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
|
||||
|
||||
Then open the file Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/SDKSettings.plist and add the versions of iOS you want to deploy to the key Root/DefaultProperties/DEPLOYMENT_TARGET_SUGGESTED_VALUES
|
||||
|
||||
Open your project and set your deployment target to the desired version of iOS
|
||||
|
||||
Finally, remove GameController from the list of frameworks linked by your application and edit the build settings for "Other Linker Flags" and add -weak_framework GameController
|
|
@ -1,90 +0,0 @@
|
|||
Linux
|
||||
================================================================================
|
||||
|
||||
By default SDL will only link against glibc, the rest of the features will be
|
||||
enabled dynamically at runtime depending on the available features on the target
|
||||
system. So, for example if you built SDL with Xinerama support and the target
|
||||
system does not have the Xinerama libraries installed, it will be disabled
|
||||
at runtime, and you won't get a missing library error, at least with the
|
||||
default configuration parameters.
|
||||
|
||||
|
||||
================================================================================
|
||||
Build Dependencies
|
||||
================================================================================
|
||||
|
||||
Ubuntu 13.04, all available features enabled:
|
||||
|
||||
sudo apt-get install build-essential mercurial make cmake autoconf automake \
|
||||
libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \
|
||||
libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \
|
||||
libxss-dev libgl1-mesa-dev libesd0-dev libdbus-1-dev libudev-dev \
|
||||
libgles1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev \
|
||||
fcitx-libs-dev libsamplerate0-dev libsndio-dev
|
||||
|
||||
Ubuntu 16.04+ can also add "libwayland-dev libxkbcommon-dev wayland-protocols"
|
||||
to that command line for Wayland support.
|
||||
|
||||
Ubuntu 16.10 can also add "libmirclient-dev libxkbcommon-dev" to that command
|
||||
line for Mir support.
|
||||
|
||||
NOTES:
|
||||
- This includes all the audio targets except arts, because Ubuntu pulled the
|
||||
artsc0-dev package, but in theory SDL still supports it.
|
||||
- libsamplerate0-dev lets SDL optionally link to libresamplerate at runtime
|
||||
for higher-quality audio resampling. SDL will work without it if the library
|
||||
is missing, so it's safe to build in support even if the end user doesn't
|
||||
have this library installed.
|
||||
- DirectFB isn't included because the configure script (currently) fails to find
|
||||
it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the
|
||||
configure script to include DirectFB support. Send patches. :)
|
||||
|
||||
|
||||
================================================================================
|
||||
Joystick does not work
|
||||
================================================================================
|
||||
|
||||
If you compiled or are using a version of SDL with udev support (and you should!)
|
||||
there's a few issues that may cause SDL to fail to detect your joystick. To
|
||||
debug this, start by installing the evtest utility. On Ubuntu/Debian:
|
||||
|
||||
sudo apt-get install evtest
|
||||
|
||||
Then run:
|
||||
|
||||
sudo evtest
|
||||
|
||||
You'll hopefully see your joystick listed along with a name like "/dev/input/eventXX"
|
||||
Now run:
|
||||
|
||||
cat /dev/input/event/XX
|
||||
|
||||
If you get a permission error, you need to set a udev rule to change the mode of
|
||||
your device (see below)
|
||||
|
||||
Also, try:
|
||||
|
||||
sudo udevadm info --query=all --name=input/eventXX
|
||||
|
||||
If you see a line stating ID_INPUT_JOYSTICK=1, great, if you don't see it,
|
||||
you need to set up an udev rule to force this variable.
|
||||
|
||||
A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks
|
||||
like:
|
||||
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
|
||||
You can set up similar rules for your device by changing the values listed in
|
||||
idProduct and idVendor. To obtain these values, try:
|
||||
|
||||
sudo udevadm info -a --name=input/eventXX | grep idVendor
|
||||
sudo udevadm info -a --name=input/eventXX | grep idProduct
|
||||
|
||||
If multiple values come up for each of these, the one you want is the first one of each.
|
||||
|
||||
On other systems which ship with an older udev (such as CentOS), you may need
|
||||
to set up a rule such as:
|
||||
|
||||
SUBSYSTEM=="input", ENV{ID_CLASS}=="joystick", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
|
|
@ -1,240 +0,0 @@
|
|||
Mac OS X
|
||||
==============================================================================
|
||||
|
||||
These instructions are for people using Apple's Mac OS X (pronounced
|
||||
"ten").
|
||||
|
||||
From the developer's point of view, OS X is a sort of hybrid Mac and
|
||||
Unix system, and you have the option of using either traditional
|
||||
command line tools or Apple's IDE Xcode.
|
||||
|
||||
Command Line Build
|
||||
==================
|
||||
|
||||
To build SDL using the command line, use the standard configure and make
|
||||
process:
|
||||
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
|
||||
You can also build SDL as a Universal library (a single binary for both
|
||||
32-bit and 64-bit Intel architectures), on Mac OS X 10.7 and newer, by using
|
||||
the gcc-fat.sh script in build-scripts:
|
||||
|
||||
mkdir mybuild
|
||||
cd mybuild
|
||||
CC=$PWD/../build-scripts/gcc-fat.sh CXX=$PWD/../build-scripts/g++-fat.sh ../configure
|
||||
make
|
||||
sudo make install
|
||||
|
||||
This script builds SDL with 10.5 ABI compatibility on i386 and 10.6
|
||||
ABI compatibility on x86_64 architectures. For best compatibility you
|
||||
should compile your application the same way.
|
||||
|
||||
Please note that building SDL requires at least Xcode 4.6 and the 10.7 SDK
|
||||
(even if you target back to 10.5 systems). PowerPC support for Mac OS X has
|
||||
been officially dropped as of SDL 2.0.2.
|
||||
|
||||
To use the library once it's built, you essential have two possibilities:
|
||||
use the traditional autoconf/automake/make method, or use Xcode.
|
||||
|
||||
==============================================================================
|
||||
Caveats for using SDL with Mac OS X
|
||||
==============================================================================
|
||||
|
||||
Some things you have to be aware of when using SDL on Mac OS X:
|
||||
|
||||
- If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
|
||||
SDL will not register its own. This means that SDL will not terminate using
|
||||
SDL_Quit if it receives a termination request, it will terminate like a
|
||||
normal app, and it will not send a SDL_DROPFILE when you request to open a
|
||||
file with the app. To solve these issues, put the following code in your
|
||||
NSApplicationDelegate implementation:
|
||||
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_DROPFILE;
|
||||
event.drop.file = SDL_strdup([filename UTF8String]);
|
||||
return (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
==============================================================================
|
||||
Using the Simple DirectMedia Layer with a traditional Makefile
|
||||
==============================================================================
|
||||
|
||||
An existing autoconf/automake build system for your SDL app has good chances
|
||||
to work almost unchanged on OS X. However, to produce a "real" Mac OS X binary
|
||||
that you can distribute to users, you need to put the generated binary into a
|
||||
so called "bundle", which basically is a fancy folder with a name like
|
||||
"MyCoolGame.app".
|
||||
|
||||
To get this build automatically, add something like the following rule to
|
||||
your Makefile.am:
|
||||
|
||||
bundle_contents = APP_NAME.app/Contents
|
||||
APP_NAME_bundle: EXE_NAME
|
||||
mkdir -p $(bundle_contents)/MacOS
|
||||
mkdir -p $(bundle_contents)/Resources
|
||||
echo "APPL????" > $(bundle_contents)/PkgInfo
|
||||
$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
|
||||
|
||||
You should replace EXE_NAME with the name of the executable. APP_NAME is what
|
||||
will be visible to the user in the Finder. Usually it will be the same
|
||||
as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME
|
||||
usually is "TestGame". You might also want to use `@PACKAGE@` to use the package
|
||||
name as specified in your configure.in file.
|
||||
|
||||
If your project builds more than one application, you will have to do a bit
|
||||
more. For each of your target applications, you need a separate rule.
|
||||
|
||||
If you want the created bundles to be installed, you may want to add this
|
||||
rule to your Makefile.am:
|
||||
|
||||
install-exec-hook: APP_NAME_bundle
|
||||
rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
|
||||
mkdir -p $(DESTDIR)$(prefix)/Applications/
|
||||
cp -r $< /$(DESTDIR)$(prefix)Applications/
|
||||
|
||||
This rule takes the Bundle created by the rule from step 3 and installs them
|
||||
into "$(DESTDIR)$(prefix)/Applications/".
|
||||
|
||||
Again, if you want to install multiple applications, you will have to augment
|
||||
the make rule accordingly.
|
||||
|
||||
|
||||
But beware! That is only part of the story! With the above, you end up with
|
||||
a bare bone .app bundle, which is double clickable from the Finder. But
|
||||
there are some more things you should do before shipping your product...
|
||||
|
||||
1) The bundle right now probably is dynamically linked against SDL. That
|
||||
means that when you copy it to another computer, *it will not run*,
|
||||
unless you also install SDL on that other computer. A good solution
|
||||
for this dilemma is to static link against SDL. On OS X, you can
|
||||
achieve that by linking against the libraries listed by
|
||||
|
||||
sdl-config --static-libs
|
||||
|
||||
instead of those listed by
|
||||
|
||||
sdl-config --libs
|
||||
|
||||
Depending on how exactly SDL is integrated into your build systems, the
|
||||
way to achieve that varies, so I won't describe it here in detail
|
||||
|
||||
2) Add an 'Info.plist' to your application. That is a special XML file which
|
||||
contains some meta-information about your application (like some copyright
|
||||
information, the version of your app, the name of an optional icon file,
|
||||
and other things). Part of that information is displayed by the Finder
|
||||
when you click on the .app, or if you look at the "Get Info" window.
|
||||
More information about Info.plist files can be found on Apple's homepage.
|
||||
|
||||
|
||||
As a final remark, let me add that I use some of the techniques (and some
|
||||
variations of them) in Exult and ScummVM; both are available in source on
|
||||
the net, so feel free to take a peek at them for inspiration!
|
||||
|
||||
|
||||
==============================================================================
|
||||
Using the Simple DirectMedia Layer with Xcode
|
||||
==============================================================================
|
||||
|
||||
These instructions are for using Apple's Xcode IDE to build SDL applications.
|
||||
|
||||
- First steps
|
||||
|
||||
The first thing to do is to unpack the Xcode.tar.gz archive in the
|
||||
top level SDL directory (where the Xcode.tar.gz archive resides).
|
||||
Because Stuffit Expander will unpack the archive into a subdirectory,
|
||||
you should unpack the archive manually from the command line:
|
||||
|
||||
cd [path_to_SDL_source]
|
||||
tar zxf Xcode.tar.gz
|
||||
|
||||
This will create a new folder called Xcode, which you can browse
|
||||
normally from the Finder.
|
||||
|
||||
- Building the Framework
|
||||
|
||||
The SDL Library is packaged as a framework bundle, an organized
|
||||
relocatable folder hierarchy of executable code, interface headers,
|
||||
and additional resources. For practical purposes, you can think of a
|
||||
framework as a more user and system-friendly shared library, whose library
|
||||
file behaves more or less like a standard UNIX shared library.
|
||||
|
||||
To build the framework, simply open the framework project and build it.
|
||||
By default, the framework bundle "SDL.framework" is installed in
|
||||
/Library/Frameworks. Therefore, the testers and project stationary expect
|
||||
it to be located there. However, it will function the same in any of the
|
||||
following locations:
|
||||
|
||||
~/Library/Frameworks
|
||||
/Local/Library/Frameworks
|
||||
/System/Library/Frameworks
|
||||
|
||||
- Build Options
|
||||
There are two "Build Styles" (See the "Targets" tab) for SDL.
|
||||
"Deployment" should be used if you aren't tweaking the SDL library.
|
||||
"Development" should be used to debug SDL apps or the library itself.
|
||||
|
||||
- Building the Testers
|
||||
Open the SDLTest project and build away!
|
||||
|
||||
- Using the Project Stationary
|
||||
Copy the stationary to the indicated folders to access it from
|
||||
the "New Project" and "Add target" menus. What could be easier?
|
||||
|
||||
- Setting up a new project by hand
|
||||
Some of you won't want to use the Stationary so I'll give some tips:
|
||||
* Create a new "Cocoa Application"
|
||||
* Add src/main/macosx/SDLMain.m , .h and .nib to your project
|
||||
* Remove "main.c" from your project
|
||||
* Remove "MainMenu.nib" from your project
|
||||
* Add "$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
|
||||
* Add "$(HOME)/Library/Frameworks" to the frameworks search path
|
||||
* Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS"
|
||||
* Set the "Main Nib File" under "Application Settings" to "SDLMain.nib"
|
||||
* Add your files
|
||||
* Clean and build
|
||||
|
||||
- Building from command line
|
||||
Use pbxbuild in the same directory as your .pbproj file
|
||||
|
||||
- Running your app
|
||||
You can send command line args to your app by either invoking it from
|
||||
the command line (in *.app/Contents/MacOS) or by entering them in the
|
||||
"Executables" panel of the target settings.
|
||||
|
||||
- Implementation Notes
|
||||
Some things that may be of interest about how it all works...
|
||||
* Working directory
|
||||
As defined in the SDL_main.m file, the working directory of your SDL app
|
||||
is by default set to its parent. You may wish to change this to better
|
||||
suit your needs.
|
||||
* You have a Cocoa App!
|
||||
Your SDL app is essentially a Cocoa application. When your app
|
||||
starts up and the libraries finish loading, a Cocoa procedure is called,
|
||||
which sets up the working directory and calls your main() method.
|
||||
You are free to modify your Cocoa app with generally no consequence
|
||||
to SDL. You cannot, however, easily change the SDL window itself.
|
||||
Functionality may be added in the future to help this.
|
||||
|
||||
|
||||
Known bugs are listed in the file "BUGS.txt".
|
|
@ -1,103 +0,0 @@
|
|||
Native Client
|
||||
================================================================================
|
||||
|
||||
Requirements:
|
||||
|
||||
* Native Client SDK (https://developer.chrome.com/native-client),
|
||||
(tested with Pepper version 33 or higher).
|
||||
|
||||
The SDL backend for Chrome's Native Client has been tested only with the PNaCl
|
||||
toolchain, which generates binaries designed to run on ARM and x86_32/64
|
||||
platforms. This does not mean it won't work with the other toolchains!
|
||||
|
||||
================================================================================
|
||||
Building SDL for NaCl
|
||||
================================================================================
|
||||
|
||||
Set up the right environment variables (see naclbuild.sh), then configure SDL with:
|
||||
|
||||
configure --host=pnacl --prefix some/install/destination
|
||||
|
||||
Then "make".
|
||||
|
||||
As an example of how to create a deployable app a Makefile project is provided
|
||||
in test/nacl/Makefile, which includes some monkey patching of the common.mk file
|
||||
provided by NaCl, without which linking properly to SDL won't work (the search
|
||||
path can't be modified externally, so the linker won't find SDL's binaries unless
|
||||
you dump them into the SDK path, which is inconvenient).
|
||||
Also provided in test/nacl is the required support file, such as index.html,
|
||||
manifest.json, etc.
|
||||
SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure.
|
||||
This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem),
|
||||
hiding the asynchronous nature of the browser behind the scenes...which is not the
|
||||
same as making it disappear!
|
||||
|
||||
|
||||
================================================================================
|
||||
Running tests
|
||||
================================================================================
|
||||
|
||||
Due to the nature of NaCl programs, building and running SDL tests is not as
|
||||
straightforward as one would hope. The script naclbuild.sh in build-scripts
|
||||
automates the process and should serve as a guide for users of SDL trying to build
|
||||
their own applications.
|
||||
|
||||
Basic usage:
|
||||
|
||||
./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35)
|
||||
|
||||
This will build testgles2.c by default.
|
||||
|
||||
If you want to build a different test, for example testrendercopyex.c:
|
||||
|
||||
SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35
|
||||
|
||||
Once the build finishes, you have to serve the contents with a web server (the
|
||||
script will give you instructions on how to do that with Python).
|
||||
|
||||
================================================================================
|
||||
RWops and nacl_io
|
||||
================================================================================
|
||||
|
||||
SDL_RWops work transparently with nacl_io. Two functions control the mount points:
|
||||
|
||||
int mount(const char* source, const char* target,
|
||||
const char* filesystemtype,
|
||||
unsigned long mountflags, const void *data);
|
||||
int umount(const char *target);
|
||||
|
||||
For convenience, SDL will by default mount an httpfs tree at / before calling
|
||||
the app's main function. Such setting can be overridden by calling:
|
||||
|
||||
umount("/");
|
||||
|
||||
And then mounting a different filesystem at /
|
||||
|
||||
It's important to consider that the asynchronous nature of file operations on a
|
||||
browser is hidden from the application, effectively providing the developer with
|
||||
a set of blocking file operations just like you get in a regular desktop
|
||||
environment, which eases the job of porting to Native Client, but also introduces
|
||||
a set of challenges of its own, in particular when big file sizes and slow
|
||||
connections are involved.
|
||||
|
||||
For more information on how nacl_io and mount points work, see:
|
||||
|
||||
https://developer.chrome.com/native-client/devguide/coding/nacl_io
|
||||
https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h
|
||||
|
||||
To be able to save into the directory "/save/" (like backup of game) :
|
||||
|
||||
mount("", "/save", "html5fs", 0, "type=PERSISTENT");
|
||||
|
||||
And add to manifest.json :
|
||||
|
||||
"permissions": [
|
||||
"unlimitedStorage"
|
||||
]
|
||||
|
||||
================================================================================
|
||||
TODO - Known Issues
|
||||
================================================================================
|
||||
* Testing of all systems with a real application (something other than SDL's tests)
|
||||
* Key events don't seem to work properly
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
Pandora
|
||||
=====================================================================
|
||||
|
||||
( http://openpandora.org/ )
|
||||
- A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES
|
||||
support to work on the pandora under the framebuffer. This driver do not have
|
||||
input support for now, so if you use it you will have to add your own control code.
|
||||
The video driver name is "pandora" so if you have problem running it from
|
||||
the framebuffer, try to set the following variable before starting your application :
|
||||
"export SDL_VIDEODRIVER=pandora"
|
||||
|
||||
- OpenGL ES support was added to the x11 driver, so it's working like the normal
|
||||
x11 driver one with OpenGLX support, with SDL input event's etc..
|
||||
|
||||
|
||||
David Carré (Cpasjuste)
|
||||
cpasjuste@gmail.com
|
|
@ -1,8 +0,0 @@
|
|||
Platforms
|
||||
=========
|
||||
|
||||
We maintain the list of supported platforms on our wiki now, and how to
|
||||
build and install SDL for those platforms:
|
||||
|
||||
https://wiki.libsdl.org/Installation
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
Porting
|
||||
=======
|
||||
|
||||
* Porting To A New Platform
|
||||
|
||||
The first thing you have to do when porting to a new platform, is look at
|
||||
include/SDL_platform.h and create an entry there for your operating system.
|
||||
The standard format is "__PLATFORM__", where PLATFORM is the name of the OS.
|
||||
Ideally SDL_platform.h will be able to auto-detect the system it's building
|
||||
on based on C preprocessor symbols.
|
||||
|
||||
There are two basic ways of building SDL at the moment:
|
||||
|
||||
1. The "UNIX" way: ./configure; make; make install
|
||||
|
||||
If you have a GNUish system, then you might try this. Edit configure.in,
|
||||
take a look at the large section labelled:
|
||||
|
||||
"Set up the configuration based on the host platform!"
|
||||
|
||||
Add a section for your platform, and then re-run autogen.sh and build!
|
||||
|
||||
2. Using an IDE:
|
||||
|
||||
If you're using an IDE or other non-configure build system, you'll probably
|
||||
want to create a custom SDL_config.h for your platform. Edit SDL_config.h,
|
||||
add a section for your platform, and create a custom SDL_config_{platform}.h,
|
||||
based on SDL_config_minimal.h and SDL_config.h.in
|
||||
|
||||
Add the top level include directory to the header search path, and then add
|
||||
the following sources to the project:
|
||||
|
||||
src/*.c
|
||||
src/atomic/*.c
|
||||
src/audio/*.c
|
||||
src/cpuinfo/*.c
|
||||
src/events/*.c
|
||||
src/file/*.c
|
||||
src/haptic/*.c
|
||||
src/joystick/*.c
|
||||
src/power/*.c
|
||||
src/render/*.c
|
||||
src/render/software/*.c
|
||||
src/stdlib/*.c
|
||||
src/thread/*.c
|
||||
src/timer/*.c
|
||||
src/video/*.c
|
||||
src/audio/disk/*.c
|
||||
src/audio/dummy/*.c
|
||||
src/filesystem/dummy/*.c
|
||||
src/video/dummy/*.c
|
||||
src/haptic/dummy/*.c
|
||||
src/joystick/dummy/*.c
|
||||
src/main/dummy/*.c
|
||||
src/thread/generic/*.c
|
||||
src/timer/dummy/*.c
|
||||
src/loadso/dummy/*.c
|
||||
|
||||
|
||||
Once you have a working library without any drivers, you can go back to each
|
||||
of the major subsystems and start implementing drivers for your platform.
|
||||
|
||||
If you have any questions, don't hesitate to ask on the SDL mailing list:
|
||||
http://www.libsdl.org/mailing-list.php
|
||||
|
||||
Enjoy!
|
||||
Sam Lantinga (slouken@libsdl.org)
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
PSP
|
||||
======
|
||||
SDL port for the Sony PSP contributed by
|
||||
Captian Lex
|
||||
|
||||
Credit to
|
||||
Marcus R.Brown,Jim Paris,Matthew H for the original SDL 1.2 for PSP
|
||||
Geecko for his PSP GU lib "Glib2d"
|
||||
|
||||
Building
|
||||
--------
|
||||
To build for the PSP, make sure psp-config is in the path and run:
|
||||
make -f Makefile.psp
|
||||
|
||||
|
||||
|
||||
To Do
|
||||
------
|
||||
PSP Screen Keyboard
|
|
@ -1,188 +0,0 @@
|
|||
Raspberry Pi
|
||||
================================================================================
|
||||
|
||||
Requirements:
|
||||
|
||||
Raspbian (other Linux distros may work as well).
|
||||
|
||||
================================================================================
|
||||
Features
|
||||
================================================================================
|
||||
|
||||
* Works without X11
|
||||
* Hardware accelerated OpenGL ES 2.x
|
||||
* Sound via ALSA
|
||||
* Input (mouse/keyboard/joystick) via EVDEV
|
||||
* Hotplugging of input devices via UDEV
|
||||
|
||||
|
||||
================================================================================
|
||||
Raspbian Build Dependencies
|
||||
================================================================================
|
||||
|
||||
sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
|
||||
|
||||
You also need the VideoCore binary stuff that ships in /opt/vc for EGL and
|
||||
OpenGL ES 2.x, it usually comes pre-installed, but in any case:
|
||||
|
||||
sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
|
||||
|
||||
|
||||
================================================================================
|
||||
NEON
|
||||
================================================================================
|
||||
|
||||
If your Pi has NEON support, make sure you add -mfpu=neon to your CFLAGS so
|
||||
that SDL will select some otherwise-disabled highly-optimized code. The
|
||||
original Pi units don't have NEON, the Pi2 probably does, and the Pi3
|
||||
definitely does.
|
||||
|
||||
================================================================================
|
||||
Cross compiling from x86 Linux
|
||||
================================================================================
|
||||
|
||||
To cross compile SDL for Raspbian from your desktop machine, you'll need a
|
||||
Raspbian system root and the cross compilation tools. We'll assume these tools
|
||||
will be placed in /opt/rpi-tools
|
||||
|
||||
sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
|
||||
|
||||
You'll also need a Raspbian binary image.
|
||||
Get it from: http://downloads.raspberrypi.org/raspbian_latest
|
||||
After unzipping, you'll get file with a name like: "<date>-wheezy-raspbian.img"
|
||||
Let's assume the sysroot will be built in /opt/rpi-sysroot.
|
||||
|
||||
export SYSROOT=/opt/rpi-sysroot
|
||||
sudo kpartx -a -v <path_to_raspbian_image>.img
|
||||
sudo mount -o loop /dev/mapper/loop0p2 /mnt
|
||||
sudo cp -r /mnt $SYSROOT
|
||||
sudo apt-get install qemu binfmt-support qemu-user-static
|
||||
sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
|
||||
sudo mount --bind /dev $SYSROOT/dev
|
||||
sudo mount --bind /proc $SYSROOT/proc
|
||||
sudo mount --bind /sys $SYSROOT/sys
|
||||
|
||||
Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
|
||||
edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
|
||||
|
||||
sudo chroot $SYSROOT
|
||||
apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev
|
||||
exit
|
||||
sudo umount $SYSROOT/dev
|
||||
sudo umount $SYSROOT/proc
|
||||
sudo umount $SYSROOT/sys
|
||||
sudo umount /mnt
|
||||
|
||||
There's one more fix required, as the libdl.so symlink uses an absolute path
|
||||
which doesn't quite work in our setup.
|
||||
|
||||
sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||
sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||
|
||||
The final step is compiling SDL itself.
|
||||
|
||||
export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux"
|
||||
cd <SDL SOURCE>
|
||||
mkdir -p build;cd build
|
||||
LDFLAGS="-L$SYSROOT/opt/vc/lib" ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
|
||||
make
|
||||
make install
|
||||
|
||||
To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths:
|
||||
|
||||
perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config
|
||||
|
||||
================================================================================
|
||||
Apps don't work or poor video/audio performance
|
||||
================================================================================
|
||||
|
||||
If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to
|
||||
update the RPi's firmware. Note that doing so will fix these problems, but it
|
||||
will also render the CMA - Dynamic Memory Split functionality useless.
|
||||
|
||||
Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
|
||||
low in general, specially if a 1080p TV is hooked up.
|
||||
|
||||
See here how to configure this setting: http://elinux.org/RPiconfig
|
||||
|
||||
Using a fixed gpu_mem=128 is the best option (specially if you updated the
|
||||
firmware, using CMA probably won't work, at least it's the current case).
|
||||
|
||||
================================================================================
|
||||
No input
|
||||
================================================================================
|
||||
|
||||
Make sure you belong to the "input" group.
|
||||
|
||||
sudo usermod -aG input `whoami`
|
||||
|
||||
================================================================================
|
||||
No HDMI Audio
|
||||
================================================================================
|
||||
|
||||
If you notice that ALSA works but there's no audio over HDMI, try adding:
|
||||
|
||||
hdmi_drive=2
|
||||
|
||||
to your config.txt file and reboot.
|
||||
|
||||
Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
|
||||
|
||||
================================================================================
|
||||
Text Input API support
|
||||
================================================================================
|
||||
|
||||
The Text Input API is supported, with translation of scan codes done via the
|
||||
kernel symbol tables. For this to work, SDL needs access to a valid console.
|
||||
If you notice there's no SDL_TEXTINPUT message being emitted, double check that
|
||||
your app has read access to one of the following:
|
||||
|
||||
* /proc/self/fd/0
|
||||
* /dev/tty
|
||||
* /dev/tty[0...6]
|
||||
* /dev/vc/0
|
||||
* /dev/console
|
||||
|
||||
This is usually not a problem if you run from the physical terminal (as opposed
|
||||
to running from a pseudo terminal, such as via SSH). If running from a PTS, a
|
||||
quick workaround is to run your app as root or add yourself to the tty group,
|
||||
then re-login to the system.
|
||||
|
||||
sudo usermod -aG tty `whoami`
|
||||
|
||||
The keyboard layout used by SDL is the same as the one the kernel uses.
|
||||
To configure the layout on Raspbian:
|
||||
|
||||
sudo dpkg-reconfigure keyboard-configuration
|
||||
|
||||
To configure the locale, which controls which keys are interpreted as letters,
|
||||
this determining the CAPS LOCK behavior:
|
||||
|
||||
sudo dpkg-reconfigure locales
|
||||
|
||||
================================================================================
|
||||
OpenGL problems
|
||||
================================================================================
|
||||
|
||||
If you have desktop OpenGL headers installed at build time in your RPi or cross
|
||||
compilation environment, support for it will be built in. However, the chipset
|
||||
does not actually have support for it, which causes issues in certain SDL apps
|
||||
since the presence of OpenGL support supersedes the ES/ES2 variants.
|
||||
The workaround is to disable OpenGL at configuration time:
|
||||
|
||||
./configure --disable-video-opengl
|
||||
|
||||
Or if the application uses the Render functions, you can use the SDL_RENDER_DRIVER
|
||||
environment variable:
|
||||
|
||||
export SDL_RENDER_DRIVER=opengles2
|
||||
|
||||
================================================================================
|
||||
Notes
|
||||
================================================================================
|
||||
|
||||
* When launching apps remotely (via SSH), SDL can prevent local keystrokes from
|
||||
leaking into the console only if it has root privileges. Launching apps locally
|
||||
does not suffer from this issue.
|
||||
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
Touch
|
||||
===========================================================================
|
||||
System Specific Notes
|
||||
===========================================================================
|
||||
Linux:
|
||||
The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it.
|
||||
|
||||
Mac:
|
||||
The Mac and iPhone APIs are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do.
|
||||
|
||||
iPhone:
|
||||
Works out of box.
|
||||
|
||||
Windows:
|
||||
Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com
|
||||
|
||||
===========================================================================
|
||||
Events
|
||||
===========================================================================
|
||||
SDL_FINGERDOWN:
|
||||
Sent when a finger (or stylus) is placed on a touch device.
|
||||
Fields:
|
||||
* event.tfinger.touchId - the Id of the touch device.
|
||||
* event.tfinger.fingerId - the Id of the finger which just went down.
|
||||
* event.tfinger.x - the x coordinate of the touch (0..1)
|
||||
* event.tfinger.y - the y coordinate of the touch (0..1)
|
||||
* event.tfinger.pressure - the pressure of the touch (0..1)
|
||||
|
||||
SDL_FINGERMOTION:
|
||||
Sent when a finger (or stylus) is moved on the touch device.
|
||||
Fields:
|
||||
Same as SDL_FINGERDOWN but with additional:
|
||||
* event.tfinger.dx - change in x coordinate during this motion event.
|
||||
* event.tfinger.dy - change in y coordinate during this motion event.
|
||||
|
||||
SDL_FINGERUP:
|
||||
Sent when a finger (or stylus) is lifted from the touch device.
|
||||
Fields:
|
||||
Same as SDL_FINGERDOWN.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Functions
|
||||
===========================================================================
|
||||
SDL provides the ability to access the underlying SDL_Finger structures.
|
||||
These structures should _never_ be modified.
|
||||
|
||||
The following functions are included from SDL_touch.h
|
||||
|
||||
To get a SDL_TouchID call SDL_GetTouchDevice(int index).
|
||||
This returns a SDL_TouchID.
|
||||
IMPORTANT: If the touch has been removed, or there is no touch with the given index, SDL_GetTouchDevice() will return 0. Be sure to check for this!
|
||||
|
||||
The number of touch devices can be queried with SDL_GetNumTouchDevices().
|
||||
|
||||
A SDL_TouchID may be used to get pointers to SDL_Finger.
|
||||
|
||||
SDL_GetNumTouchFingers(touchID) may be used to get the number of fingers currently down on the device.
|
||||
|
||||
The most common reason to access SDL_Finger is to query the fingers outside the event. In most cases accessing the fingers is using the event. This would be accomplished by code like the following:
|
||||
|
||||
float x = event.tfinger.x;
|
||||
float y = event.tfinger.y;
|
||||
|
||||
|
||||
|
||||
To get a SDL_Finger, call SDL_GetTouchFinger(SDL_TouchID touchID, int index), where touchID is a SDL_TouchID, and index is the requested finger.
|
||||
This returns a SDL_Finger *, or NULL if the finger does not exist, or has been removed.
|
||||
A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the SDL_FINGERUP event is polled.
|
||||
As a result, be very careful to check for NULL return values.
|
||||
|
||||
A SDL_Finger has the following fields:
|
||||
* x, y:
|
||||
The current coordinates of the touch.
|
||||
* pressure:
|
||||
The pressure of the touch.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
||||
(original author, API was changed since)
|
|
@ -1,10 +0,0 @@
|
|||
WinCE
|
||||
=====
|
||||
|
||||
Windows CE is no longer supported by SDL.
|
||||
|
||||
We have left the CE support in SDL 1.2 for those that must have it, and we
|
||||
have support for Windows Phone 8 and WinRT in SDL2, as of SDL 2.0.3.
|
||||
|
||||
--ryan.
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
Windows
|
||||
================================================================================
|
||||
|
||||
================================================================================
|
||||
OpenGL ES 2.x support
|
||||
================================================================================
|
||||
|
||||
SDL has support for OpenGL ES 2.x under Windows via two alternative
|
||||
implementations.
|
||||
The most straightforward method consists in running your app in a system with
|
||||
a graphic card paired with a relatively recent (as of November of 2013) driver
|
||||
which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
|
||||
to ship said extension on Windows currently include nVidia and Intel.
|
||||
|
||||
The other method involves using the ANGLE library (https://code.google.com/p/angleproject/)
|
||||
If an OpenGL ES 2.x context is requested and no WGL_EXT_create_context_es2_profile
|
||||
extension is found, SDL will try to load the libEGL.dll library provided by
|
||||
ANGLE.
|
||||
To obtain the ANGLE binaries, you can either compile from source from
|
||||
https://chromium.googlesource.com/angle/angle or copy the relevant binaries from
|
||||
a recent Chrome/Chromium install for Windows. The files you need are:
|
||||
|
||||
* libEGL.dll
|
||||
* libGLESv2.dll
|
||||
* d3dcompiler_46.dll (supports Windows Vista or later, better shader compiler)
|
||||
or...
|
||||
* d3dcompiler_43.dll (supports Windows XP or later)
|
||||
|
||||
If you compile ANGLE from source, you can configure it so it does not need the
|
||||
d3dcompiler_* DLL at all (for details on this, see their documentation).
|
||||
However, by default SDL will try to preload the d3dcompiler_46.dll to
|
||||
comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to
|
||||
support Windows XP) or to skip this step at all, you can use the
|
||||
SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details).
|
||||
|
||||
Known Bugs:
|
||||
|
||||
* SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
|
||||
that there's a bug in the library which prevents the window contents from
|
||||
refreshing if this is set to anything other than the default value.
|
||||
|
||||
Vulkan Surface Support
|
||||
==============
|
||||
|
||||
Support for creating Vulkan surfaces is configured on by default. To disable it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to use Vulkan graphics in your application.
|
|
@ -1,544 +0,0 @@
|
|||
WinRT
|
||||
=====
|
||||
|
||||
This port allows SDL applications to run on Microsoft's platforms that require
|
||||
use of "Windows Runtime", aka. "WinRT", APIs. Microsoft may, in some cases,
|
||||
refer to them as either "Windows Store", or for Windows 10, "UWP" apps.
|
||||
|
||||
Some of the operating systems that include WinRT, are:
|
||||
|
||||
* Windows 10, via its Universal Windows Platform (UWP) APIs
|
||||
* Windows 8.x
|
||||
* Windows RT 8.x (aka. Windows 8.x for ARM processors)
|
||||
* Windows Phone 8.x
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* Microsoft Visual C++ (aka Visual Studio), either 2017, 2015, 2013, or 2012
|
||||
- Free, "Community" or "Express" editions may be used, so long as they
|
||||
include support for either "Windows Store" or "Windows Phone" apps.
|
||||
"Express" versions marked as supporting "Windows Desktop" development
|
||||
typically do not include support for creating WinRT apps, to note.
|
||||
(The "Community" editions of Visual C++ do, however, support both
|
||||
desktop/Win32 and WinRT development).
|
||||
- Visual Studio 2017 can be used, however it is recommended that you install
|
||||
the Visual C++ 2015 build tools. These build tools can be installed
|
||||
using VS 2017's installer. Be sure to also install the workload for
|
||||
"Universal Windows Platform development", its optional component, the
|
||||
"C++ Universal Windows Platform tools", and for UWP / Windows 10
|
||||
development, the "Windows 10 SDK (10.0.10240.0)". Please note that
|
||||
targeting UWP / Windows 10 apps from development machine(s) running
|
||||
earlier versions of Windows, such as Windows 7, is not always supported
|
||||
by Visual Studio, and you may get error(s) when attempting to do so.
|
||||
- Visual C++ 2012 can only build apps that target versions 8.0 of Windows,
|
||||
or Windows Phone. 8.0-targeted apps will run on devices running 8.1
|
||||
editions of Windows, however they will not be able to take advantage of
|
||||
8.1-specific features.
|
||||
- Visual C++ 2013 cannot create app projects that target Windows 8.0.
|
||||
Visual C++ 2013 Update 4, can create app projects for Windows Phone 8.0,
|
||||
Windows Phone 8.1, and Windows 8.1, but not Windows 8.0. An optional
|
||||
Visual Studio add-in, "Tools for Maintaining Store apps for Windows 8",
|
||||
allows Visual C++ 2013 to load and build Windows 8.0 projects that were
|
||||
created with Visual C++ 2012, so long as Visual C++ 2012 is installed
|
||||
on the same machine. More details on targeting different versions of
|
||||
Windows can found at the following web pages:
|
||||
- [Develop apps by using Visual Studio 2013](http://msdn.microsoft.com/en-us/library/windows/apps/br211384.aspx)
|
||||
- [To add the Tools for Maintaining Store apps for Windows 8](http://msdn.microsoft.com/en-us/library/windows/apps/dn263114.aspx#AddMaintenanceTools)
|
||||
* A valid Microsoft account - This requirement is not imposed by SDL, but
|
||||
rather by Microsoft's Visual C++ toolchain. This is required to launch or
|
||||
debug apps.
|
||||
|
||||
|
||||
Status
|
||||
------
|
||||
|
||||
Here is a rough list of what works, and what doesn't:
|
||||
|
||||
* What works:
|
||||
* compilation via Visual C++ 2012 through 2015
|
||||
* compile-time platform detection for SDL programs. The C/C++ #define,
|
||||
`__WINRT__`, will be set to 1 (by SDL) when compiling for WinRT.
|
||||
* GPU-accelerated 2D rendering, via SDL_Renderer.
|
||||
* OpenGL ES 2, via the ANGLE library (included separately from SDL)
|
||||
* software rendering, via either SDL_Surface (optionally in conjunction with
|
||||
SDL_GetWindowSurface() and SDL_UpdateWindowSurface()) or via the
|
||||
SDL_Renderer APIs
|
||||
* threads
|
||||
* timers (via SDL_GetTicks(), SDL_AddTimer(), SDL_GetPerformanceCounter(),
|
||||
SDL_GetPerformanceFrequency(), etc.)
|
||||
* file I/O via SDL_RWops
|
||||
* mouse input (unsupported on Windows Phone)
|
||||
* audio, via SDL's WASAPI backend (if you want to record, your app must
|
||||
have "Microphone" capabilities enabled in its manifest, and the user must
|
||||
not have blocked access. Otherwise, capture devices will fail to work,
|
||||
presenting as a device disconnect shortly after opening it.)
|
||||
* .DLL file loading. Libraries *MUST* be packaged inside applications. Loading
|
||||
anything outside of the app is not supported.
|
||||
* system path retrieval via SDL's filesystem APIs
|
||||
* game controllers. Support is provided via the SDL_Joystick and
|
||||
SDL_GameController APIs, and is backed by Microsoft's XInput API. Please
|
||||
note, however, that Windows limits game-controller support in UWP apps to,
|
||||
"Xbox compatible controllers" (many controllers that work in Win32 apps,
|
||||
do not work in UWP, due to restrictions in UWP itself.)
|
||||
* multi-touch input
|
||||
* app events. SDL_APP_WILLENTER* and SDL_APP_DIDENTER* events get sent out as
|
||||
appropriate.
|
||||
* window events
|
||||
* using Direct3D 11.x APIs outside of SDL. Non-XAML / Direct3D-only apps can
|
||||
choose to render content directly via Direct3D, using SDL to manage the
|
||||
internal WinRT window, as well as input and audio. (Use
|
||||
SDL_GetWindowWMInfo() to get the WinRT 'CoreWindow', and pass it into
|
||||
IDXGIFactory2::CreateSwapChainForCoreWindow() as appropriate.)
|
||||
|
||||
* What partially works:
|
||||
* keyboard input. Most of WinRT's documented virtual keys are supported, as
|
||||
well as many keys with documented hardware scancodes. Converting
|
||||
SDL_Scancodes to or from SDL_Keycodes may not work, due to missing APIs
|
||||
(MapVirtualKey()) in Microsoft's Windows Store / UWP APIs.
|
||||
* SDLmain. WinRT uses a different signature for each app's main() function.
|
||||
SDL-based apps that use this port must compile in SDL_winrt_main_NonXAML.cpp
|
||||
(in `SDL\src\main\winrt\`) directly in order for their C-style main()
|
||||
functions to be called.
|
||||
|
||||
* What doesn't work:
|
||||
* compilation with anything other than Visual C++
|
||||
* programmatically-created custom cursors. These don't appear to be supported
|
||||
by WinRT. Different OS-provided cursors can, however, be created via
|
||||
SDL_CreateSystemCursor() (unsupported on Windows Phone)
|
||||
* SDL_WarpMouseInWindow() or SDL_WarpMouseGlobal(). This are not currently
|
||||
supported by WinRT itself.
|
||||
* joysticks and game controllers that either are not supported by
|
||||
Microsoft's XInput API, or are not supported within UWP apps (many
|
||||
controllers that work in Win32, do not work in UWP, due to restrictions in
|
||||
UWP itself).
|
||||
* turning off VSync when rendering on Windows Phone. Attempts to turn VSync
|
||||
off on Windows Phone result either in Direct3D not drawing anything, or it
|
||||
forcing VSync back on. As such, SDL_RENDERER_PRESENTVSYNC will always get
|
||||
turned-on on Windows Phone. This limitation is not present in non-Phone
|
||||
WinRT (such as Windows 8.x), where turning off VSync appears to work.
|
||||
* probably anything else that's not listed as supported
|
||||
|
||||
|
||||
|
||||
Upgrade Notes
|
||||
-------------
|
||||
|
||||
#### SDL_GetPrefPath() usage when upgrading WinRT apps from SDL 2.0.3
|
||||
|
||||
SDL 2.0.4 fixes two bugs found in the WinRT version of SDL_GetPrefPath().
|
||||
The fixes may affect older, SDL 2.0.3-based apps' save data. Please note
|
||||
that these changes only apply to SDL-based WinRT apps, and not to apps for
|
||||
any other platform.
|
||||
|
||||
1. SDL_GetPrefPath() would return an invalid path, one in which the path's
|
||||
directory had not been created. Attempts to create files there
|
||||
(via fopen(), for example), would fail, unless that directory was
|
||||
explicitly created beforehand.
|
||||
|
||||
2. SDL_GetPrefPath(), for non-WinPhone-based apps, would return a path inside
|
||||
a WinRT 'Roaming' folder, the contents of which get automatically
|
||||
synchronized across multiple devices. This process can occur while an
|
||||
application runs, and can cause existing save-data to be overwritten
|
||||
at unexpected times, with data from other devices. (Windows Phone apps
|
||||
written with SDL 2.0.3 did not utilize a Roaming folder, due to API
|
||||
restrictions in Windows Phone 8.0).
|
||||
|
||||
|
||||
SDL_GetPrefPath(), starting with SDL 2.0.4, addresses these by:
|
||||
|
||||
1. making sure that SDL_GetPrefPath() returns a directory in which data
|
||||
can be written to immediately, without first needing to create directories.
|
||||
|
||||
2. basing SDL_GetPrefPath() off of a different, non-Roaming folder, the
|
||||
contents of which do not automatically get synchronized across devices
|
||||
(and which require less work to use safely, in terms of data integrity).
|
||||
|
||||
Apps that wish to get their Roaming folder's path can do so either by using
|
||||
SDL_WinRTGetFSPathUTF8(), SDL_WinRTGetFSPathUNICODE() (which returns a
|
||||
UCS-2/wide-char string), or directly through the WinRT class,
|
||||
Windows.Storage.ApplicationData.
|
||||
|
||||
|
||||
|
||||
Setup, High-Level Steps
|
||||
-----------------------
|
||||
|
||||
The steps for setting up a project for an SDL/WinRT app looks like the
|
||||
following, at a high-level:
|
||||
|
||||
1. create a new Visual C++ project using Microsoft's template for a,
|
||||
"Direct3D App".
|
||||
2. remove most of the files from the project.
|
||||
3. make your app's project directly reference SDL/WinRT's own Visual C++
|
||||
project file, via use of Visual C++'s "References" dialog. This will setup
|
||||
the linker, and will copy SDL's .dll files to your app's final output.
|
||||
4. adjust your app's build settings, at minimum, telling it where to find SDL's
|
||||
header files.
|
||||
5. add files that contains a WinRT-appropriate main function, along with some
|
||||
data to make sure mouse-cursor-hiding (via SDL_ShowCursor(SDL_DISABLE) calls)
|
||||
work properly.
|
||||
6. add SDL-specific app code.
|
||||
7. build and run your app.
|
||||
|
||||
|
||||
Setup, Detailed Steps
|
||||
---------------------
|
||||
|
||||
### 1. Create a new project ###
|
||||
|
||||
Create a new project using one of Visual C++'s templates for a plain, non-XAML,
|
||||
"Direct3D App" (XAML support for SDL/WinRT is not yet ready for use). If you
|
||||
don't see one of these templates, in Visual C++'s 'New Project' dialog, try
|
||||
using the textbox titled, 'Search Installed Templates' to look for one.
|
||||
|
||||
|
||||
### 2. Remove unneeded files from the project ###
|
||||
|
||||
In the new project, delete any file that has one of the following extensions:
|
||||
|
||||
- .cpp
|
||||
- .h
|
||||
- .hlsl
|
||||
|
||||
When you are done, you should be left with a few files, each of which will be a
|
||||
necessary part of your app's project. These files will consist of:
|
||||
|
||||
- an .appxmanifest file, which contains metadata on your WinRT app. This is
|
||||
similar to an Info.plist file on iOS, or an AndroidManifest.xml on Android.
|
||||
- a few .png files, one of which is a splash screen (displayed when your app
|
||||
launches), others are app icons.
|
||||
- a .pfx file, used for code signing purposes.
|
||||
|
||||
|
||||
### 3. Add references to SDL's project files ###
|
||||
|
||||
SDL/WinRT can be built in multiple variations, spanning across three different
|
||||
CPU architectures (x86, x64, and ARM) and two different configurations
|
||||
(Debug and Release). WinRT and Visual C++ do not currently provide a means
|
||||
for combining multiple variations of one library into a single file.
|
||||
Furthermore, it does not provide an easy means for copying pre-built .dll files
|
||||
into your app's final output (via Post-Build steps, for example). It does,
|
||||
however, provide a system whereby an app can reference the MSVC projects of
|
||||
libraries such that, when the app is built:
|
||||
|
||||
1. each library gets built for the appropriate CPU architecture(s) and WinRT
|
||||
platform(s).
|
||||
2. each library's output, such as .dll files, get copied to the app's build
|
||||
output.
|
||||
|
||||
To set this up for SDL/WinRT, you'll need to run through the following steps:
|
||||
|
||||
1. open up the Solution Explorer inside Visual C++ (under the "View" menu, then
|
||||
"Solution Explorer")
|
||||
2. right click on your app's solution.
|
||||
3. navigate to "Add", then to "Existing Project..."
|
||||
4. find SDL/WinRT's Visual C++ project file and open it. Different project
|
||||
files exist for different WinRT platforms. All of them are in SDL's
|
||||
source distribution, in the following directories:
|
||||
* `VisualC-WinRT/UWP_VS2015/` - for Windows 10 / UWP apps
|
||||
* `VisualC-WinRT/WinPhone81_VS2013/` - for Windows Phone 8.1 apps
|
||||
* `VisualC-WinRT/WinRT80_VS2012/` - for Windows 8.0 apps
|
||||
* `VisualC-WinRT/WinRT81_VS2013/` - for Windows 8.1 apps
|
||||
5. once the project has been added, right-click on your app's project and
|
||||
select, "References..."
|
||||
6. click on the button titled, "Add New Reference..."
|
||||
7. check the box next to SDL
|
||||
8. click OK to close the dialog
|
||||
9. SDL will now show up in the list of references. Click OK to close that
|
||||
dialog.
|
||||
|
||||
Your project is now linked to SDL's project, insofar that when the app is
|
||||
built, SDL will be built as well, with its build output getting included with
|
||||
your app.
|
||||
|
||||
|
||||
### 4. Adjust Your App's Build Settings ###
|
||||
|
||||
Some build settings need to be changed in your app's project. This guide will
|
||||
outline the following:
|
||||
|
||||
- making sure that the compiler knows where to find SDL's header files
|
||||
- **Optional for C++, but NECESSARY for compiling C code:** telling the
|
||||
compiler not to use Microsoft's C++ extensions for WinRT development.
|
||||
- **Optional:** telling the compiler not generate errors due to missing
|
||||
precompiled header files.
|
||||
|
||||
To change these settings:
|
||||
|
||||
1. right-click on the project
|
||||
2. choose "Properties"
|
||||
3. in the drop-down box next to "Configuration", choose, "All Configurations"
|
||||
4. in the drop-down box next to "Platform", choose, "All Platforms"
|
||||
5. in the left-hand list, expand the "C/C++" section
|
||||
6. select "General"
|
||||
7. edit the "Additional Include Directories" setting, and add a path to SDL's
|
||||
"include" directory
|
||||
8. **Optional: to enable compilation of C code:** change the setting for
|
||||
"Consume Windows Runtime Extension" from "Yes (/ZW)" to "No". If you're
|
||||
working with a completely C++ based project, this step can usually be
|
||||
omitted.
|
||||
9. **Optional: to disable precompiled headers (which can produce
|
||||
'stdafx.h'-related build errors, if setup incorrectly:** in the left-hand
|
||||
list, select "Precompiled Headers", then change the setting for "Precompiled
|
||||
Header" from "Use (/Yu)" to "Not Using Precompiled Headers".
|
||||
10. close the dialog, saving settings, by clicking the "OK" button
|
||||
|
||||
|
||||
### 5. Add a WinRT-appropriate main function, and a blank-cursor image, to the app. ###
|
||||
|
||||
A few files should be included directly in your app's MSVC project, specifically:
|
||||
1. a WinRT-appropriate main function (which is different than main() functions on
|
||||
other platforms)
|
||||
2. a Win32-style cursor resource, used by SDL_ShowCursor() to hide the mouse cursor
|
||||
(if and when the app needs to do so). *If this cursor resource is not
|
||||
included, mouse-position reporting may fail if and when the cursor is
|
||||
hidden, due to possible bugs/design-oddities in Windows itself.*
|
||||
|
||||
To include these files:
|
||||
|
||||
1. right-click on your project (again, in Visual C++'s Solution Explorer),
|
||||
navigate to "Add", then choose "Existing Item...".
|
||||
2. navigate to the directory containing SDL's source code, then into its
|
||||
subdirectory, 'src/main/winrt/'. Select, then add, the following files:
|
||||
- `SDL_winrt_main_NonXAML.cpp`
|
||||
- `SDL2-WinRTResources.rc`
|
||||
- `SDL2-WinRTResource_BlankCursor.cur`
|
||||
3. right-click on the file `SDL_winrt_main_NonXAML.cpp` (as listed in your
|
||||
project), then click on "Properties...".
|
||||
4. in the drop-down box next to "Configuration", choose, "All Configurations"
|
||||
5. in the drop-down box next to "Platform", choose, "All Platforms"
|
||||
6. in the left-hand list, click on "C/C++"
|
||||
7. change the setting for "Consume Windows Runtime Extension" to "Yes (/ZW)".
|
||||
8. click the OK button. This will close the dialog.
|
||||
|
||||
|
||||
**NOTE: C++/CX compilation is currently required in at least one file of your
|
||||
app's project. This is to make sure that Visual C++'s linker builds a 'Windows
|
||||
Metadata' file (.winmd) for your app. Not doing so can lead to build errors.**
|
||||
|
||||
|
||||
### 6. Add app code and assets ###
|
||||
|
||||
At this point, you can add in SDL-specific source code. Be sure to include a
|
||||
C-style main function (ie: `int main(int argc, char *argv[])`). From there you
|
||||
should be able to create a single `SDL_Window` (WinRT apps can only have one
|
||||
window, at present), as well as an `SDL_Renderer`. Direct3D will be used to
|
||||
draw content. Events are received via SDL's usual event functions
|
||||
(`SDL_PollEvent`, etc.) If you have a set of existing source files and assets,
|
||||
you can start adding them to the project now. If not, or if you would like to
|
||||
make sure that you're setup correctly, some short and simple sample code is
|
||||
provided below.
|
||||
|
||||
|
||||
#### 6.A. ... when creating a new app ####
|
||||
|
||||
If you are creating a new app (rather than porting an existing SDL-based app),
|
||||
or if you would just like a simple app to test SDL/WinRT with before trying to
|
||||
get existing code working, some working SDL/WinRT code is provided below. To
|
||||
set this up:
|
||||
|
||||
1. right click on your app's project
|
||||
2. select Add, then New Item. An "Add New Item" dialog will show up.
|
||||
3. from the left-hand list, choose "Visual C++"
|
||||
4. from the middle/main list, choose "C++ File (.cpp)"
|
||||
5. near the bottom of the dialog, next to "Name:", type in a name for your
|
||||
source file, such as, "main.cpp".
|
||||
6. click on the Add button. This will close the dialog, add the new file to
|
||||
your project, and open the file in Visual C++'s text editor.
|
||||
7. Copy and paste the following code into the new file, then save it.
|
||||
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
SDL_Window * window = NULL;
|
||||
SDL_Renderer * renderer = NULL;
|
||||
SDL_Event evt;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
while (SDL_PollEvent(&evt)) {
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#### 6.B. Adding code and assets ####
|
||||
|
||||
If you have existing code and assets that you'd like to add, you should be able
|
||||
to add them now. The process for adding a set of files is as such.
|
||||
|
||||
1. right click on the app's project
|
||||
2. select Add, then click on "New Item..."
|
||||
3. open any source, header, or asset files as appropriate. Support for C and
|
||||
C++ is available.
|
||||
|
||||
Do note that WinRT only supports a subset of the APIs that are available to
|
||||
Win32-based apps. Many portions of the Win32 API and the C runtime are not
|
||||
available.
|
||||
|
||||
A list of unsupported C APIs can be found at
|
||||
<http://msdn.microsoft.com/en-us/library/windows/apps/jj606124.aspx>
|
||||
|
||||
General information on using the C runtime in WinRT can be found at
|
||||
<https://msdn.microsoft.com/en-us/library/hh972425.aspx>
|
||||
|
||||
A list of supported Win32 APIs for WinRT apps can be found at
|
||||
<http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx>. To note,
|
||||
the list of supported Win32 APIs for Windows Phone 8.0 is different.
|
||||
That list can be found at
|
||||
<http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662956(v=vs.105).aspx>
|
||||
|
||||
|
||||
### 7. Build and run your app ###
|
||||
|
||||
Your app project should now be setup, and you should be ready to build your app.
|
||||
To run it on the local machine, open the Debug menu and choose "Start
|
||||
Debugging". This will build your app, then run your app full-screen. To switch
|
||||
out of your app, press the Windows key. Alternatively, you can choose to run
|
||||
your app in a window. To do this, before building and running your app, find
|
||||
the drop-down menu in Visual C++'s toolbar that says, "Local Machine". Expand
|
||||
this by clicking on the arrow on the right side of the list, then click on
|
||||
Simulator. Once you do that, any time you build and run the app, the app will
|
||||
launch in window, rather than full-screen.
|
||||
|
||||
|
||||
#### 7.A. Running apps on older, ARM-based, "Windows RT" devices ####
|
||||
|
||||
**These instructions do not include Windows Phone, despite Windows Phone
|
||||
typically running on ARM processors.** They are specifically for devices
|
||||
that use the "Windows RT" operating system, which was a modified version of
|
||||
Windows 8.x that ran primarily on ARM-based tablet computers.
|
||||
|
||||
To build and run the app on ARM-based, "Windows RT" devices, you'll need to:
|
||||
|
||||
- install Microsoft's "Remote Debugger" on the device. Visual C++ installs and
|
||||
debugs ARM-based apps via IP networks.
|
||||
- change a few options on the development machine, both to make sure it builds
|
||||
for ARM (rather than x86 or x64), and to make sure it knows how to find the
|
||||
Windows RT device (on the network).
|
||||
|
||||
Microsoft's Remote Debugger can be found at
|
||||
<https://msdn.microsoft.com/en-us/library/hh441469.aspx>. Please note
|
||||
that separate versions of this debugger exist for different versions of Visual
|
||||
C++, one each for MSVC 2015, 2013, and 2012.
|
||||
|
||||
To setup Visual C++ to launch your app on an ARM device:
|
||||
|
||||
1. make sure the Remote Debugger is running on your ARM device, and that it's on
|
||||
the same IP network as your development machine.
|
||||
2. from Visual C++'s toolbar, find a drop-down menu that says, "Win32". Click
|
||||
it, then change the value to "ARM".
|
||||
3. make sure Visual C++ knows the hostname or IP address of the ARM device. To
|
||||
do this:
|
||||
1. open the app project's properties
|
||||
2. select "Debugging"
|
||||
3. next to "Machine Name", enter the hostname or IP address of the ARM
|
||||
device
|
||||
4. if, and only if, you've turned off authentication in the Remote Debugger,
|
||||
then change the setting for "Require Authentication" to No
|
||||
5. click "OK"
|
||||
4. build and run the app (from Visual C++). The first time you do this, a
|
||||
prompt will show up on the ARM device, asking for a Microsoft Account. You
|
||||
do, unfortunately, need to log in here, and will need to follow the
|
||||
subsequent registration steps in order to launch the app. After you do so,
|
||||
if the app didn't already launch, try relaunching it again from within Visual
|
||||
C++.
|
||||
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
#### Build fails with message, "error LNK2038: mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker'"
|
||||
|
||||
Try adding the following to your linker flags. In MSVC, this can be done by
|
||||
right-clicking on the app project, navigating to Configuration Properties ->
|
||||
Linker -> Command Line, then adding them to the Additional Options
|
||||
section.
|
||||
|
||||
* For Release builds / MSVC-Configurations, add:
|
||||
|
||||
/nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib
|
||||
|
||||
* For Debug builds / MSVC-Configurations, add:
|
||||
|
||||
/nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib
|
||||
|
||||
|
||||
#### Mouse-motion events fail to get sent, or SDL_GetMouseState() fails to return updated values
|
||||
|
||||
This may be caused by a bug in Windows itself, whereby hiding the mouse
|
||||
cursor can cause mouse-position reporting to fail.
|
||||
|
||||
SDL provides a workaround for this, but it requires that an app links to a
|
||||
set of Win32-style cursor image-resource files. A copy of suitable resource
|
||||
files can be found in `src/main/winrt/`. Adding them to an app's Visual C++
|
||||
project file should be sufficient to get the app to use them.
|
||||
|
||||
|
||||
#### SDL's Visual Studio project file fails to open, with message, "The system can't find the file specified."
|
||||
|
||||
This can be caused for any one of a few reasons, which Visual Studio can
|
||||
report, but won't always do so in an up-front manner.
|
||||
|
||||
To help determine why this error comes up:
|
||||
|
||||
1. open a copy of Visual Studio without opening a project file. This can be
|
||||
accomplished via Windows' Start Menu, among other means.
|
||||
2. show Visual Studio's Output window. This can be done by going to VS'
|
||||
menu bar, then to View, and then to Output.
|
||||
3. try opening the SDL project file directly by going to VS' menu bar, then
|
||||
to File, then to Open, then to Project/Solution. When a File-Open dialog
|
||||
appears, open the SDL project (such as the one in SDL's source code, in its
|
||||
directory, VisualC-WinRT/UWP_VS2015/).
|
||||
4. after attempting to open SDL's Visual Studio project file, additional error
|
||||
information will be output to the Output window.
|
||||
|
||||
If Visual Studio reports (via its Output window) that the project:
|
||||
|
||||
"could not be loaded because it's missing install components. To fix this launch Visual Studio setup with the following selections:
|
||||
Microsoft.VisualStudio.ComponentGroup.UWP.VC"
|
||||
|
||||
... then you will need to re-launch Visual Studio's installer, and make sure that
|
||||
the workflow for "Universal Windows Platform development" is checked, and that its
|
||||
optional component, "C++ Universal Windows Platform tools" is also checked. While
|
||||
you are there, if you are planning on targeting UWP / Windows 10, also make sure
|
||||
that you check the optional component, "Windows 10 SDK (10.0.10240.0)". After
|
||||
making sure these items are checked as-appropriate, install them.
|
||||
|
||||
Once you install these components, try re-launching Visual Studio, and re-opening
|
||||
the SDL project file. If you still get the error dialog, try using the Output
|
||||
window, again, seeing what Visual Studio says about it.
|
||||
|
||||
|
||||
#### Game controllers / joysticks aren't working!
|
||||
|
||||
Windows only permits certain game controllers and joysticks to work within
|
||||
WinRT / UWP apps. Even if a game controller or joystick works in a Win32
|
||||
app, that device is not guaranteed to work inside a WinRT / UWP app.
|
||||
|
||||
According to Microsoft, "Xbox compatible controllers" should work inside
|
||||
UWP apps, potentially with more working in the future. This includes, but
|
||||
may not be limited to, Microsoft-made Xbox controllers and USB adapters.
|
||||
(Source: https://social.msdn.microsoft.com/Forums/en-US/9064838b-e8c3-4c18-8a83-19bf0dfe150d/xinput-fails-to-detect-game-controllers?forum=wpdevelop)
|
||||
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
Simple DirectMedia Layer {#mainpage}
|
||||
========================
|
||||
|
||||
(SDL)
|
||||
|
||||
Version 2.0
|
||||
|
||||
---
|
||||
http://www.libsdl.org/
|
||||
|
||||
Simple DirectMedia Layer is a cross-platform development library designed
|
||||
to provide low level access to audio, keyboard, mouse, joystick, and graphics
|
||||
hardware via OpenGL and Direct3D. It is used by video playback software,
|
||||
emulators, and popular games including Valve's award winning catalog
|
||||
and many Humble Bundle games.
|
||||
|
||||
SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.
|
||||
Support for other platforms may be found in the source code.
|
||||
|
||||
SDL is written in C, works natively with C++, and there are bindings
|
||||
available for several other languages, including C# and Python.
|
||||
|
||||
This library is distributed under the zlib license, which can be found
|
||||
in the file "COPYING.txt".
|
||||
|
||||
The best way to learn how to use SDL is to check out the header files in
|
||||
the "include" subdirectory and the programs in the "test" subdirectory.
|
||||
The header files and test programs are well commented and always up to date.
|
||||
|
||||
More documentation and FAQs are available online at [the wiki](http://wiki.libsdl.org/)
|
||||
|
||||
- [Android](README-android.md)
|
||||
- [CMake](README-cmake.md)
|
||||
- [DirectFB](README-directfb.md)
|
||||
- [DynAPI](README-dynapi.md)
|
||||
- [Emscripten](README-emscripten.md)
|
||||
- [Gesture](README-gesture.md)
|
||||
- [Mercurial](README-hg.md)
|
||||
- [iOS](README-ios.md)
|
||||
- [Linux](README-linux.md)
|
||||
- [OS X](README-macosx.md)
|
||||
- [Native Client](README-nacl.md)
|
||||
- [Pandora](README-pandora.md)
|
||||
- [Supported Platforms](README-platforms.md)
|
||||
- [Porting information](README-porting.md)
|
||||
- [PSP](README-psp.md)
|
||||
- [Raspberry Pi](README-raspberrypi.md)
|
||||
- [Touch](README-touch.md)
|
||||
- [WinCE](README-wince.md)
|
||||
- [Windows](README-windows.md)
|
||||
- [WinRT](README-winrt.md)
|
||||
|
||||
If you need help with the library, or just want to discuss SDL related
|
||||
issues, you can join the [developers mailing list](http://www.libsdl.org/mailing-list.php)
|
||||
|
||||
If you want to report bugs or contribute patches, please submit them to
|
||||
[bugzilla](https://bugzilla.libsdl.org/)
|
||||
|
||||
Enjoy!
|
||||
|
||||
|
||||
Sam Lantinga <mailto:slouken@libsdl.org>
|
||||
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,73 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Adjuster widget header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Adjuster widget . */
|
||||
|
||||
// 3-button "slider", made for Nuke
|
||||
|
||||
#ifndef Fl_Adjuster_H
|
||||
#define Fl_Adjuster_H
|
||||
|
||||
#ifndef Fl_Valuator_H
|
||||
#include "Fl_Valuator.H"
|
||||
#endif
|
||||
|
||||
/**
|
||||
The Fl_Adjuster widget was stolen from Prisms, and has proven
|
||||
to be very useful for values that need a large dynamic range.
|
||||
\image html adjuster1.png
|
||||
\image latex adjuster1.png "Fl_Adjuster" width=4cm
|
||||
<P>When you press a button and drag to the right the value increases.
|
||||
When you drag to the left it decreases. The largest button adjusts by
|
||||
100 * step(), the next by 10 * step() and that
|
||||
smallest button by step(). Clicking on the buttons
|
||||
increments by 10 times the amount dragging by a pixel does. Shift +
|
||||
click decrements by 10 times the amount.
|
||||
*/
|
||||
class FL_EXPORT Fl_Adjuster : public Fl_Valuator {
|
||||
int drag;
|
||||
int ix;
|
||||
int soft_;
|
||||
protected:
|
||||
void draw();
|
||||
int handle(int);
|
||||
void value_damage();
|
||||
public:
|
||||
Fl_Adjuster(int X,int Y,int W,int H,const char *l=0);
|
||||
/**
|
||||
If "soft" is turned on, the user is allowed to drag the value outside
|
||||
the range. If they drag the value to one of the ends, let go, then
|
||||
grab again and continue to drag, they can get to any value. Default is
|
||||
one.
|
||||
*/
|
||||
void soft(int s) {soft_ = s;}
|
||||
/**
|
||||
If "soft" is turned on, the user is allowed to drag the value outside
|
||||
the range. If they drag the value to one of the ends, let go, then
|
||||
grab again and continue to drag, they can get to any value. Default is
|
||||
one.
|
||||
*/
|
||||
int soft() const {return soft_;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,41 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// BMP image header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_BMP_Image widget . */
|
||||
|
||||
#ifndef Fl_BMP_Image_H
|
||||
#define Fl_BMP_Image_H
|
||||
# include "Fl_Image.H"
|
||||
|
||||
/**
|
||||
The Fl_BMP_Image class supports loading, caching,
|
||||
and drawing of Windows Bitmap (BMP) image files.
|
||||
*/
|
||||
class FL_EXPORT Fl_BMP_Image : public Fl_RGB_Image {
|
||||
|
||||
public:
|
||||
|
||||
Fl_BMP_Image(const char* filename);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,78 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Bitmap header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Bitmap widget . */
|
||||
|
||||
#ifndef Fl_Bitmap_H
|
||||
#define Fl_Bitmap_H
|
||||
# include "Fl_Image.H"
|
||||
|
||||
class Fl_Widget;
|
||||
struct Fl_Menu_Item;
|
||||
|
||||
/**
|
||||
The Fl_Bitmap class supports caching and drawing of mono-color
|
||||
(bitmap) images. Images are drawn using the current color.
|
||||
*/
|
||||
class FL_EXPORT Fl_Bitmap : public Fl_Image {
|
||||
friend class Fl_Quartz_Graphics_Driver;
|
||||
friend class Fl_GDI_Graphics_Driver;
|
||||
friend class Fl_GDI_Printer_Graphics_Driver;
|
||||
friend class Fl_Xlib_Graphics_Driver;
|
||||
public:
|
||||
|
||||
/** pointer to raw bitmap data */
|
||||
const uchar *array;
|
||||
/** Non-zero if array points to bitmap data allocated internally */
|
||||
int alloc_array;
|
||||
|
||||
private:
|
||||
int start(int XP, int YP, int WP, int HP, int &cx, int &cy,
|
||||
int &X, int &Y, int &W, int &H);
|
||||
#if defined(__APPLE__) || defined(WIN32)
|
||||
/** for internal use */
|
||||
void *id_;
|
||||
#else
|
||||
/** for internal use */
|
||||
unsigned id_;
|
||||
#endif // __APPLE__ || WIN32
|
||||
|
||||
public:
|
||||
|
||||
/** The constructors create a new bitmap from the specified bitmap data */
|
||||
Fl_Bitmap(const uchar *bits, int W, int H) :
|
||||
Fl_Image(W,H,0), array(bits), alloc_array(0), id_(0) {data((const char **)&array, 1);}
|
||||
/** The constructors create a new bitmap from the specified bitmap data */
|
||||
Fl_Bitmap(const char *bits, int W, int H) :
|
||||
Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id_(0) {data((const char **)&array, 1);}
|
||||
virtual ~Fl_Bitmap();
|
||||
virtual Fl_Image *copy(int W, int H);
|
||||
Fl_Image *copy() { return copy(w(), h()); }
|
||||
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
|
||||
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
|
||||
virtual void label(Fl_Widget*w);
|
||||
virtual void label(Fl_Menu_Item*m);
|
||||
virtual void uncache();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,59 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Box header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Box widget . */
|
||||
|
||||
#ifndef Fl_Box_H
|
||||
#define Fl_Box_H
|
||||
|
||||
#ifndef Fl_Widget_H
|
||||
#include "Fl_Widget.H"
|
||||
#endif
|
||||
|
||||
/**
|
||||
This widget simply draws its box, and possibly its label. Putting it
|
||||
before some other widgets and making it big enough to surround them
|
||||
will let you draw a frame around them.
|
||||
*/
|
||||
class FL_EXPORT Fl_Box : public Fl_Widget {
|
||||
protected:
|
||||
void draw();
|
||||
public:
|
||||
/**
|
||||
- The first constructor sets box() to FL_NO_BOX, which
|
||||
means it is invisible. However such widgets are useful as placeholders
|
||||
or Fl_Group::resizable()
|
||||
values. To change the box to something visible, use box(n).
|
||||
- The second form of the constructor sets the box to the specified box
|
||||
type.
|
||||
<P>The destructor removes the box.
|
||||
*/
|
||||
Fl_Box(int X, int Y, int W, int H, const char *l=0);
|
||||
|
||||
/** See Fl_Box::Fl_Box(int x, int y, int w, int h, const char * = 0) */
|
||||
Fl_Box(Fl_Boxtype b, int X, int Y, int W, int H, const char *l);
|
||||
|
||||
virtual int handle(int);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,326 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Browser header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Browser widget . */
|
||||
|
||||
// Forms-compatible browser. Probably useful for other
|
||||
// lists of textual data. Notice that the line numbers
|
||||
// start from 1, and 0 means "no line".
|
||||
|
||||
#ifndef Fl_Browser_H
|
||||
#define Fl_Browser_H
|
||||
|
||||
#include "Fl_Browser_.H"
|
||||
#include "Fl_Image.H"
|
||||
|
||||
struct FL_BLINE;
|
||||
|
||||
/**
|
||||
The Fl_Browser widget displays a scrolling list of text
|
||||
lines, and manages all the storage for the text. This is not a text
|
||||
editor or spreadsheet! But it is useful for showing a vertical list of
|
||||
named objects to the user.
|
||||
|
||||
Each line in the browser is identified by number. <I>The numbers
|
||||
start at one</I> (this is so that zero can be reserved for "no line" in
|
||||
the selective browsers). <I>Unless otherwise noted, the methods do not
|
||||
check to see if the passed line number is in range and legal. It must
|
||||
always be greater than zero and <= size().</I>
|
||||
|
||||
Each line contains a null-terminated string of text and a void *
|
||||
data pointer. The text string is displayed, the void *
|
||||
pointer can be used by the callbacks to reference the object the text
|
||||
describes.
|
||||
|
||||
The base class does nothing when the user clicks on it. The
|
||||
subclasses
|
||||
Fl_Select_Browser,
|
||||
Fl_Hold_Browser, and
|
||||
Fl_Multi_Browser react to user clicks to select lines in
|
||||
the browser and do callbacks.
|
||||
|
||||
The base class
|
||||
Fl_Browser_ provides the scrolling and selection mechanisms of
|
||||
this and all the subclasses, but the dimensions and appearance of each
|
||||
item are determined by the subclass. You can use Fl_Browser_
|
||||
to display information other than text, or text that is dynamically
|
||||
produced from your own data structures. If you find that loading the
|
||||
browser is a lot of work or is inefficient, you may want to make a
|
||||
subclass of Fl_Browser_.
|
||||
|
||||
Some common coding patterns used for working with Fl_Browser:
|
||||
\code
|
||||
// How to loop through all the items in the browser
|
||||
for ( int t=1; t<=browser->size(); t++ ) { // index 1 based..!
|
||||
printf("item #%d, label='%s'\n", t, browser->text(t));
|
||||
}
|
||||
\endcode
|
||||
|
||||
Note: If you are <I>subclassing</I> Fl_Browser, it's more efficient
|
||||
to use the protected methods item_first() and item_next(), since
|
||||
Fl_Browser internally uses linked lists to manage the browser's items.
|
||||
For more info, see find_item(int).
|
||||
*/
|
||||
class FL_EXPORT Fl_Browser : public Fl_Browser_ {
|
||||
|
||||
FL_BLINE *first; // the array of lines
|
||||
FL_BLINE *last;
|
||||
FL_BLINE *cache;
|
||||
int cacheline; // line number of cache
|
||||
int lines; // Number of lines
|
||||
int full_height_;
|
||||
const int* column_widths_;
|
||||
char format_char_; // alternative to @-sign
|
||||
char column_char_; // alternative to tab
|
||||
|
||||
protected:
|
||||
|
||||
// required routines for Fl_Browser_ subclass:
|
||||
void* item_first() const ;
|
||||
void* item_next(void* item) const ;
|
||||
void* item_prev(void* item) const ;
|
||||
void* item_last()const ;
|
||||
int item_selected(void* item) const ;
|
||||
void item_select(void* item, int val);
|
||||
int item_height(void* item) const ;
|
||||
int item_width(void* item) const ;
|
||||
void item_draw(void* item, int X, int Y, int W, int H) const ;
|
||||
int full_height() const ;
|
||||
int incr_height() const ;
|
||||
const char *item_text(void *item) const;
|
||||
/** Swap the items \p a and \p b.
|
||||
You must call redraw() to make any changes visible.
|
||||
\param[in] a,b the items to be swapped.
|
||||
\see swap(int,int), item_swap()
|
||||
*/
|
||||
void item_swap(void *a, void *b) { swap((FL_BLINE*)a, (FL_BLINE*)b); }
|
||||
/** Return the item at specified \p line.
|
||||
\param[in] line The line of the item to return. (1 based)
|
||||
\returns The item, or NULL if line out of range.
|
||||
\see item_at(), find_line(), lineno()
|
||||
*/
|
||||
void *item_at(int line) const { return (void*)find_line(line); }
|
||||
|
||||
FL_BLINE* find_line(int line) const ;
|
||||
FL_BLINE* _remove(int line) ;
|
||||
void insert(int line, FL_BLINE* item);
|
||||
int lineno(void *item) const ;
|
||||
void swap(FL_BLINE *a, FL_BLINE *b);
|
||||
|
||||
public:
|
||||
|
||||
void remove(int line);
|
||||
void add(const char* newtext, void* d = 0);
|
||||
void insert(int line, const char* newtext, void* d = 0);
|
||||
void move(int to, int from);
|
||||
int load(const char* filename);
|
||||
void swap(int a, int b);
|
||||
void clear();
|
||||
|
||||
/**
|
||||
Returns how many lines are in the browser.
|
||||
The last line number is equal to this.
|
||||
Returns 0 if browser is empty.
|
||||
*/
|
||||
int size() const { return lines; }
|
||||
void size(int W, int H) { Fl_Widget::size(W, H); }
|
||||
|
||||
/**
|
||||
Gets the default text size (in pixels) for the lines in the browser.
|
||||
*/
|
||||
Fl_Fontsize textsize() const { return Fl_Browser_::textsize(); }
|
||||
|
||||
/*
|
||||
Sets the default text size for the lines in the browser to newSize.
|
||||
Defined and documented in Fl_Browser.cxx
|
||||
*/
|
||||
void textsize(Fl_Fontsize newSize);
|
||||
|
||||
int topline() const ;
|
||||
/** For internal use only? */
|
||||
enum Fl_Line_Position { TOP, BOTTOM, MIDDLE };
|
||||
void lineposition(int line, Fl_Line_Position pos);
|
||||
/**
|
||||
Scrolls the browser so the top item in the browser
|
||||
is showing the specified \p line.
|
||||
\param[in] line The line to be displayed at the top.
|
||||
\see topline(), middleline(), bottomline(), displayed(), lineposition()
|
||||
*/
|
||||
void topline(int line) { lineposition(line, TOP); }
|
||||
/**
|
||||
Scrolls the browser so the bottom item in the browser
|
||||
is showing the specified \p line.
|
||||
\param[in] line The line to be displayed at the bottom.
|
||||
\see topline(), middleline(), bottomline(), displayed(), lineposition()
|
||||
*/
|
||||
void bottomline(int line) { lineposition(line, BOTTOM); }
|
||||
/**
|
||||
Scrolls the browser so the middle item in the browser
|
||||
is showing the specified \p line.
|
||||
\param[in] line The line to be displayed in the middle.
|
||||
\see topline(), middleline(), bottomline(), displayed(), lineposition()
|
||||
*/
|
||||
void middleline(int line) { lineposition(line, MIDDLE); }
|
||||
|
||||
int select(int line, int val=1);
|
||||
int selected(int line) const ;
|
||||
void show(int line);
|
||||
/** Shows the entire Fl_Browser widget -- opposite of hide(). */
|
||||
void show() { Fl_Widget::show(); }
|
||||
void hide(int line);
|
||||
/** Hides the entire Fl_Browser widget -- opposite of show(). */
|
||||
void hide() { Fl_Widget::hide(); }
|
||||
int visible(int line) const ;
|
||||
|
||||
int value() const ;
|
||||
/**
|
||||
Sets the browser's value(), which selects the specified \p line.
|
||||
This is the same as calling select(line).
|
||||
\see select(), selected(), value(), item_select(), item_selected()
|
||||
*/
|
||||
void value(int line) { select(line); }
|
||||
const char* text(int line) const ;
|
||||
void text(int line, const char* newtext);
|
||||
void* data(int line) const ;
|
||||
void data(int line, void* d);
|
||||
|
||||
Fl_Browser(int X, int Y, int W, int H, const char *L = 0);
|
||||
/**
|
||||
The destructor deletes all list items and destroys the browser.
|
||||
*/
|
||||
~Fl_Browser() { clear(); }
|
||||
|
||||
/**
|
||||
Gets the current format code prefix character, which by default is '\@'.
|
||||
A string of formatting codes at the start of each column are stripped off
|
||||
and used to modify how the rest of the line is printed:
|
||||
|
||||
\li <tt>'\@.'</tt> Print rest of line, don't look for more '\@' signs
|
||||
\li <tt>'\@\@'</tt> Print rest of line starting with '\@'
|
||||
\li <tt>'\@l'</tt> Use a LARGE (24 point) font
|
||||
\li <tt>'\@m'</tt> Use a medium large (18 point) font
|
||||
\li <tt>'\@s'</tt> Use a <SMALL>small</SMALL> (11 point) font
|
||||
\li <tt>'\@b'</tt> Use a <B>bold</B> font (adds FL_BOLD to font)
|
||||
\li <tt>'\@i'</tt> Use an <I>italic</I> font (adds FL_ITALIC to font)
|
||||
\li <tt>'\@f' or '\@t'</tt> Use a fixed-pitch
|
||||
font (sets font to FL_COURIER)
|
||||
\li <tt>'\@c'</tt> Center the line horizontally
|
||||
\li <tt>'\@r'</tt> Right-justify the text
|
||||
\li <tt>'\@B0', '\@B1', ... '\@B255'</tt> Fill the backgound with
|
||||
fl_color(n)
|
||||
\li <tt>'\@C0', '\@C1', ... '\@C255'</tt> Use fl_color(n) to draw the text
|
||||
\li <tt>'\@F0', '\@F1', ...</tt> Use fl_font(n) to draw the text
|
||||
\li <tt>'\@S1', '\@S2', ...</tt> Use point size n to draw the text
|
||||
\li <tt>'\@u' or '\@_'</tt> Underline the text.
|
||||
\li <tt>'\@-'</tt> draw an engraved line through the middle.
|
||||
|
||||
Notice that the '\@.' command can be used to reliably
|
||||
terminate the parsing. To print a random string in a random color, use
|
||||
<tt>sprintf("@C%d@.%s", color, string)</tt> and it will work even if the
|
||||
string starts with a digit or has the format character in it.
|
||||
*/
|
||||
char format_char() const { return format_char_; }
|
||||
/**
|
||||
Sets the current format code prefix character to \p c.
|
||||
The default prefix is '\@'. Set the prefix to 0 to disable formatting.
|
||||
\see format_char() for list of '\@' codes
|
||||
*/
|
||||
void format_char(char c) { format_char_ = c; }
|
||||
/**
|
||||
Gets the current column separator character.
|
||||
The default is '\\t' (tab).
|
||||
\see column_char(), column_widths()
|
||||
*/
|
||||
char column_char() const { return column_char_; }
|
||||
/**
|
||||
Sets the column separator to c.
|
||||
This will only have an effect if you also set column_widths().
|
||||
The default is '\\t' (tab).
|
||||
\see column_char(), column_widths()
|
||||
*/
|
||||
void column_char(char c) { column_char_ = c; }
|
||||
/**
|
||||
Gets the current column width array.
|
||||
This array is zero-terminated and specifies the widths in pixels of
|
||||
each column. The text is split at each column_char() and each part is
|
||||
formatted into it's own column. After the last column any remaining
|
||||
text is formatted into the space between the last column and the
|
||||
right edge of the browser, even if the text contains instances of
|
||||
column_char() . The default value is a one-element array of just
|
||||
a zero, which means there are no columns.
|
||||
|
||||
Example:
|
||||
\code
|
||||
Fl_Browser *b = new Fl_Browser(..);
|
||||
static int widths[] = { 50, 50, 50, 70, 70, 40, 40, 70, 70, 50, 0 }; // widths for each column
|
||||
b->column_widths(widths); // assign array to widget
|
||||
b->column_char('\t'); // use tab as the column character
|
||||
b->add("USER\tPID\tCPU\tMEM\tVSZ\tRSS\tTTY\tSTAT\tSTART\tTIME\tCOMMAND");
|
||||
b->add("root\t2888\t0.0\t0.0\t1352\t0\ttty3\tSW\tAug15\t0:00\t@b@f/sbin/mingetty tty3");
|
||||
b->add("root\t13115\t0.0\t0.0\t1352\t0\ttty2\tSW\tAug30\t0:00\t@b@f/sbin/mingetty tty2");
|
||||
[..]
|
||||
\endcode
|
||||
\see column_char(), column_widths()
|
||||
*/
|
||||
const int* column_widths() const { return column_widths_; }
|
||||
/**
|
||||
Sets the current array to \p arr. Make sure the last entry is zero.
|
||||
\see column_char(), column_widths()
|
||||
*/
|
||||
void column_widths(const int* arr) { column_widths_ = arr; }
|
||||
|
||||
/**
|
||||
Returns non-zero if \p line has been scrolled to a position where it is being displayed.
|
||||
Checks to see if the item's vertical position is within the top and bottom
|
||||
edges of the display window. This does NOT take into account the hide()/show()
|
||||
status of the widget or item.
|
||||
\param[in] line The line to be checked
|
||||
\returns 1 if visible, 0 if not visible.
|
||||
\see topline(), middleline(), bottomline(), displayed(), lineposition()
|
||||
*/
|
||||
int displayed(int line) const { return Fl_Browser_::displayed(find_line(line)); }
|
||||
|
||||
/**
|
||||
Make the item at the specified \p line visible().
|
||||
Functionally similar to show(int line).
|
||||
If \p line is out of range, redisplay top or bottom of list as appropriate.
|
||||
\param[in] line The line to be made visible.
|
||||
\see show(int), hide(int), display(), visible(), make_visible()
|
||||
*/
|
||||
void make_visible(int line) {
|
||||
if (line < 1) Fl_Browser_::display(find_line(1));
|
||||
else if (line > lines) Fl_Browser_::display(find_line(lines));
|
||||
else Fl_Browser_::display(find_line(line));
|
||||
}
|
||||
|
||||
// icon support
|
||||
void icon(int line, Fl_Image* icon);
|
||||
Fl_Image* icon(int line) const;
|
||||
void remove_icon(int line);
|
||||
|
||||
/** For back compatibility only. */
|
||||
void replace(int a, const char* b) { text(a, b); }
|
||||
void display(int line, int val=1);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,388 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Common browser header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Browser_ widget . */
|
||||
|
||||
// Yes, I know this should be a template...
|
||||
|
||||
#ifndef Fl_Browser__H
|
||||
#define Fl_Browser__H
|
||||
|
||||
#ifndef Fl_Group_H
|
||||
#include "Fl_Group.H"
|
||||
#endif
|
||||
#include "Fl_Scrollbar.H"
|
||||
#include <FL/Fl.H> // Fl::scrollbar_size()
|
||||
|
||||
#define FL_NORMAL_BROWSER 0 /**< type() of Fl_Browser */
|
||||
#define FL_SELECT_BROWSER 1 /**< type() of FL_Select_Browser */
|
||||
#define FL_HOLD_BROWSER 2 /**< type() of Fl_Hold_Browser */
|
||||
#define FL_MULTI_BROWSER 3 /**< type() of Fl_Multi_Browser */
|
||||
|
||||
#define FL_SORT_ASCENDING 0 /**< sort browser items in ascending alphabetic order. */
|
||||
#define FL_SORT_DESCENDING 1 /**< sort in descending order */
|
||||
|
||||
/**
|
||||
This is the base class for browsers. To be useful it must be
|
||||
subclassed and several virtual functions defined. The Forms-compatible
|
||||
browser and the file chooser's browser are subclassed off of this.
|
||||
|
||||
This has been designed so that the subclass has complete control
|
||||
over the storage of the data, although because next() and
|
||||
prev() functions are used to index, it works best as a linked list
|
||||
or as a large block of characters in which the line breaks must be
|
||||
searched for.
|
||||
|
||||
A great deal of work has been done so that the "height" of a data
|
||||
object does not need to be determined until it is drawn. This is
|
||||
useful if actually figuring out the size of an object requires
|
||||
accessing image data or doing stat() on a file or doing some
|
||||
other slow operation.
|
||||
|
||||
Keyboard navigation of browser items
|
||||
------------------------------------
|
||||
The keyboard navigation of browser items is only possible if
|
||||
visible_focus() is enabled. If disabled, the widget rejects keyboard focus;
|
||||
Tab and Shift-Tab focus navigation will skip the widget.
|
||||
|
||||
In 'Select' and 'Normal' mode, the widget rejects keyboard focus;
|
||||
no navigation keys are supported (other than scrollbar positioning).
|
||||
|
||||
In 'Hold' mode, the widget accepts keyboard focus, and Up/Down arrow
|
||||
keys can navigate the selected item.
|
||||
|
||||
In 'Multi' mode, the widget accepts keyboard focus, and Up/Down arrow
|
||||
keys navigate the focus box; Space toggles the current item's selection,
|
||||
Enter selects only the current item (deselects all others). If Shift
|
||||
(or Ctrl) is combined with Up/Down arrow keys, the current item's
|
||||
selection state is extended to the next item. In this way one can
|
||||
extend a selection or de-selection.
|
||||
*/
|
||||
class FL_EXPORT Fl_Browser_ : public Fl_Group {
|
||||
int position_; // where user wants it scrolled to
|
||||
int real_position_; // the current vertical scrolling position
|
||||
int hposition_; // where user wants it panned to
|
||||
int real_hposition_; // the current horizontal scrolling position
|
||||
int offset_; // how far down top_ item the real_position is
|
||||
int max_width; // widest object seen so far
|
||||
uchar has_scrollbar_; // which scrollbars are enabled
|
||||
Fl_Font textfont_;
|
||||
Fl_Fontsize textsize_;
|
||||
Fl_Color textcolor_;
|
||||
void* top_; // which item scrolling position is in
|
||||
void* selection_; // which is selected (except for FL_MULTI_BROWSER)
|
||||
void *redraw1,*redraw2; // minimal update pointers
|
||||
void* max_width_item; // which item has max_width_
|
||||
int scrollbar_size_; // size of scrollbar trough
|
||||
|
||||
void update_top();
|
||||
|
||||
protected:
|
||||
|
||||
// All of the following must be supplied by the subclass:
|
||||
/**
|
||||
This method must be provided by the subclass
|
||||
to return the first item in the list.
|
||||
\see item_first(), item_next(), item_last(), item_prev()
|
||||
*/
|
||||
virtual void *item_first() const = 0;
|
||||
/**
|
||||
This method must be provided by the subclass
|
||||
to return the item in the list after \p item.
|
||||
\see item_first(), item_next(), item_last(), item_prev()
|
||||
*/
|
||||
virtual void *item_next(void *item) const = 0;
|
||||
/**
|
||||
This method must be provided by the subclass
|
||||
to return the item in the list before \p item.
|
||||
\see item_first(), item_next(), item_last(), item_prev()
|
||||
*/
|
||||
virtual void *item_prev(void *item) const = 0;
|
||||
/**
|
||||
This method must be provided by the subclass
|
||||
to return the last item in the list.
|
||||
\see item_first(), item_next(), item_last(), item_prev()
|
||||
*/
|
||||
virtual void *item_last() const { return 0L; }
|
||||
/**
|
||||
This method must be provided by the subclass to return
|
||||
the height of \p item in pixels.
|
||||
Allow for two additional pixels for the list selection box.
|
||||
\param[in] item The item whose height is returned.
|
||||
\returns The height of the specified \p item in pixels.
|
||||
\see item_height(), item_width(), item_quick_height()
|
||||
*/
|
||||
virtual int item_height(void *item) const = 0;
|
||||
/**
|
||||
This method must be provided by the subclass to return the width of the
|
||||
\p item in pixels. Allow for two additional pixels for the list
|
||||
selection box.
|
||||
\param[in] item The item whose width is returned.
|
||||
\returns The width of the item in pixels.
|
||||
*/
|
||||
virtual int item_width(void *item) const = 0;
|
||||
virtual int item_quick_height(void *item) const ;
|
||||
/**
|
||||
This method must be provided by the subclass to draw the \p item
|
||||
in the area indicated by \p X, \p Y, \p W, \p H.
|
||||
*/
|
||||
virtual void item_draw(void *item,int X,int Y,int W,int H) const = 0;
|
||||
/**
|
||||
This optional method returns a string (label) that may be used for sorting.
|
||||
\param[in] item The item whose label text is returned.
|
||||
\returns The item's text label. (Can be NULL if blank)
|
||||
*/
|
||||
virtual const char *item_text(void *item) const { (void)item; return 0L; }
|
||||
/**
|
||||
This optional method should be provided by the subclass
|
||||
to efficiently swap browser items \p a and \p b, such as for sorting.
|
||||
\param[in] a,b The two items to be swapped.
|
||||
*/
|
||||
virtual void item_swap(void *a,void *b) { (void)a; (void)b; }
|
||||
/**
|
||||
This method must be provided by the subclass
|
||||
to return the item for the specified \p index.
|
||||
\param[in] index The \p index of the item to be returned
|
||||
\returns The item at the specified \p index.
|
||||
*/
|
||||
virtual void *item_at(int index) const { (void)index; return 0L; }
|
||||
// you don't have to provide these but it may help speed it up:
|
||||
virtual int full_width() const ; // current width of all items
|
||||
virtual int full_height() const ; // current height of all items
|
||||
virtual int incr_height() const ; // average height of an item
|
||||
// These only need to be done by subclass if you want a multi-browser:
|
||||
virtual void item_select(void *item,int val=1);
|
||||
virtual int item_selected(void *item) const ;
|
||||
|
||||
// things the subclass may want to call:
|
||||
/**
|
||||
Returns the item that appears at the top of the list.
|
||||
*/
|
||||
void *top() const { return top_; }
|
||||
/**
|
||||
Returns the item currently selected, or NULL if there is no selection.
|
||||
|
||||
For multiple selection browsers this call returns the currently focused item,
|
||||
even if it is not selected. To find all selected items, call
|
||||
Fl_Multi_Browser::selected() for every item in question.
|
||||
*/
|
||||
void *selection() const { return selection_; }
|
||||
void new_list(); // completely clobber all data, as though list replaced
|
||||
void deleting(void *item); // get rid of any pointers to item
|
||||
void replacing(void *a,void *b); // change a pointers to b
|
||||
void swapping(void *a,void *b); // exchange pointers a and b
|
||||
void inserting(void *a,void *b); // insert b near a
|
||||
int displayed(void *item) const ; // true if this item is visible
|
||||
void redraw_line(void *item); // minimal update, no change in size
|
||||
/**
|
||||
This method will cause the entire list to be redrawn.
|
||||
\see redraw_lines(), redraw_line()
|
||||
*/
|
||||
void redraw_lines() { damage(FL_DAMAGE_SCROLL); } // redraw all of them
|
||||
void bbox(int &X,int &Y,int &W,int &H) const;
|
||||
int leftedge() const; // x position after scrollbar & border
|
||||
void *find_item(int ypos); // item under mouse
|
||||
|
||||
void draw();
|
||||
Fl_Browser_(int X,int Y,int W,int H,const char *L=0);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
Vertical scrollbar. Public, so that it can be accessed directly.
|
||||
*/
|
||||
Fl_Scrollbar scrollbar;
|
||||
/**
|
||||
Horizontal scrollbar. Public, so that it can be accessed directly.
|
||||
*/
|
||||
Fl_Scrollbar hscrollbar;
|
||||
|
||||
int handle(int event);
|
||||
void resize(int X,int Y,int W,int H);
|
||||
|
||||
int select(void *item,int val=1,int docallbacks=0);
|
||||
int select_only(void *item,int docallbacks=0);
|
||||
int deselect(int docallbacks=0);
|
||||
/**
|
||||
Gets the vertical scroll position of the list as a pixel position \p pos.
|
||||
The position returned is how many pixels of the list are scrolled off the top edge
|
||||
of the screen. Example: A position of '3' indicates the top 3 pixels of
|
||||
the list are scrolled off the top edge of the screen.
|
||||
\see position(), hposition()
|
||||
*/
|
||||
int position() const { return position_; }
|
||||
void position(int pos); // scroll to here
|
||||
/**
|
||||
Gets the horizontal scroll position of the list as a pixel position \p pos.
|
||||
The position returned is how many pixels of the list are scrolled off the left edge
|
||||
of the screen. Example: A position of '18' indicates the left 18 pixels of
|
||||
the list are scrolled off the left edge of the screen.
|
||||
\see position(), hposition()
|
||||
*/
|
||||
int hposition() const { return hposition_; }
|
||||
void hposition(int); // pan to here
|
||||
void display(void *item); // scroll so this item is shown
|
||||
|
||||
/**
|
||||
Values for has_scrollbar().
|
||||
*/
|
||||
/** Anonymous enum bit flags for has_scrollbar().
|
||||
- bit 0: horizontal
|
||||
- bit 1: vertical
|
||||
- bit 2: 'always' (to be combined with bits 0 and 1)
|
||||
- bit 3-31: reserved for future use
|
||||
*/
|
||||
enum { // values for has_scrollbar()
|
||||
HORIZONTAL = 1, ///< Only show horizontal scrollbar.
|
||||
VERTICAL = 2, ///< Only show vertical scrollbar.
|
||||
BOTH = 3, ///< Show both scrollbars. (default)
|
||||
ALWAYS_ON = 4, ///< Specified scrollbar(s) should 'always' be shown (to be used with HORIZONTAL/VERTICAL)
|
||||
HORIZONTAL_ALWAYS = 5, ///< Horizontal scrollbar always on.
|
||||
VERTICAL_ALWAYS = 6, ///< Vertical scrollbar always on.
|
||||
BOTH_ALWAYS = 7 ///< Both scrollbars always on.
|
||||
};
|
||||
/**
|
||||
Returns the current scrollbar mode, see Fl_Browser_::has_scrollbar(uchar)
|
||||
*/
|
||||
uchar has_scrollbar() const { return has_scrollbar_; }
|
||||
/**
|
||||
Sets whether the widget should have scrollbars or not (default Fl_Browser_::BOTH).
|
||||
By default you can scroll in both directions, and the scrollbars
|
||||
disappear if the data will fit in the widget.
|
||||
has_scrollbar() changes this based on the value of \p mode:
|
||||
|
||||
- 0 - No scrollbars.
|
||||
|
||||
- Fl_Browser_::HORIZONTAL - Only a horizontal scrollbar.
|
||||
|
||||
- Fl_Browser_::VERTICAL - Only a vertical scrollbar.
|
||||
|
||||
- Fl_Browser_::BOTH - The default is both scrollbars.
|
||||
|
||||
- Fl_Browser_::HORIZONTAL_ALWAYS - Horizontal scrollbar always on,
|
||||
vertical always off.
|
||||
|
||||
- Fl_Browser_::VERTICAL_ALWAYS - Vertical scrollbar always on,
|
||||
horizontal always off.
|
||||
|
||||
- Fl_Browser_::BOTH_ALWAYS - Both always on.
|
||||
*/
|
||||
void has_scrollbar(uchar mode) { has_scrollbar_ = mode; }
|
||||
|
||||
/**
|
||||
Gets the default text font for the lines in the browser.
|
||||
\see textfont(), textsize(), textcolor()
|
||||
*/
|
||||
Fl_Font textfont() const { return textfont_; }
|
||||
/**
|
||||
Sets the default text font for the lines in the browser to \p font.
|
||||
*/
|
||||
void textfont(Fl_Font font) { textfont_ = font; }
|
||||
|
||||
/**
|
||||
Gets the default text size (in pixels) for the lines in the browser.
|
||||
*/
|
||||
Fl_Fontsize textsize() const { return textsize_; }
|
||||
/**
|
||||
Sets the default text size (in pixels) for the lines in the browser to \p size.
|
||||
*/
|
||||
void textsize(Fl_Fontsize newSize) { textsize_ = newSize; }
|
||||
|
||||
/**
|
||||
Gets the default text color for the lines in the browser.
|
||||
*/
|
||||
Fl_Color textcolor() const { return textcolor_; }
|
||||
/**
|
||||
Sets the default text color for the lines in the browser to color \p col.
|
||||
*/
|
||||
void textcolor(Fl_Color col) { textcolor_ = col; }
|
||||
|
||||
/**
|
||||
Gets the current size of the scrollbars' troughs, in pixels.
|
||||
|
||||
If this value is zero (default), this widget will use the
|
||||
Fl::scrollbar_size() value as the scrollbar's width.
|
||||
|
||||
\returns Scrollbar size in pixels, or 0 if the global Fl::scrollbar_size() is being used.
|
||||
\see Fl::scrollbar_size(int)
|
||||
*/
|
||||
int scrollbar_size() const {
|
||||
return(scrollbar_size_);
|
||||
}
|
||||
/**
|
||||
Sets the pixel size of the scrollbars' troughs to \p newSize, in pixels.
|
||||
|
||||
Normally you should not need this method, and should use
|
||||
Fl::scrollbar_size(int) instead to manage the size of ALL
|
||||
your widgets' scrollbars. This ensures your application
|
||||
has a consistent UI, is the default behavior, and is normally
|
||||
what you want.
|
||||
|
||||
Only use THIS method if you really need to override the global
|
||||
scrollbar size. The need for this should be rare.
|
||||
|
||||
Setting \p newSize to the special value of 0 causes the widget to
|
||||
track the global Fl::scrollbar_size(), which is the default.
|
||||
|
||||
\param[in] newSize Sets the scrollbar size in pixels.\n
|
||||
If 0 (default), scrollbar size tracks the global Fl::scrollbar_size()
|
||||
\see Fl::scrollbar_size()
|
||||
*/
|
||||
void scrollbar_size(int newSize) {
|
||||
scrollbar_size_ = newSize;
|
||||
}
|
||||
/**
|
||||
This method has been deprecated, existing for backwards compatibility only.
|
||||
Use scrollbar_size() instead.
|
||||
This method always returns the global value Fl::scrollbar_size().
|
||||
\returns Always returns the global value Fl::scrollbar_size().
|
||||
\todo This method should eventually be removed in 1.4+
|
||||
*/
|
||||
int scrollbar_width() const {
|
||||
return(Fl::scrollbar_size());
|
||||
}
|
||||
/**
|
||||
This method has been deprecated, existing for backwards compatibility only.
|
||||
Use scrollbar_size(int) instead.
|
||||
This method sets the global Fl::scrollbar_size(), and forces this
|
||||
instance of the widget to use it.
|
||||
\todo This method should eventually be removed in 1.4+
|
||||
*/
|
||||
void scrollbar_width(int width) {
|
||||
Fl::scrollbar_size(width);
|
||||
scrollbar_size_ = 0;
|
||||
}
|
||||
/**
|
||||
Moves the vertical scrollbar to the righthand side of the list.
|
||||
For back compatibility.
|
||||
*/
|
||||
void scrollbar_right() { scrollbar.align(FL_ALIGN_RIGHT); }
|
||||
/**
|
||||
Moves the vertical scrollbar to the lefthand side of the list.
|
||||
For back compatibility.
|
||||
*/
|
||||
void scrollbar_left() { scrollbar.align(FL_ALIGN_LEFT); }
|
||||
void sort(int flags=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,176 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Button header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2014 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Button widget . */
|
||||
|
||||
#ifndef Fl_Button_H
|
||||
#define Fl_Button_H
|
||||
|
||||
#ifndef Fl_Widget_H
|
||||
#include "Fl_Widget.H"
|
||||
#endif
|
||||
|
||||
// values for type()
|
||||
#define FL_NORMAL_BUTTON 0 /**< value() will be set to 1 during the press of the button and
|
||||
reverts back to 0 when the button is released */
|
||||
#define FL_TOGGLE_BUTTON 1 ///< value() toggles between 0 and 1 at every click of the button
|
||||
#define FL_RADIO_BUTTON (FL_RESERVED_TYPE+2) /**< is set to 1 at button press, and all other
|
||||
buttons in the same group with <tt>type() == FL_RADIO_BUTTON</tt>
|
||||
are set to zero.*/
|
||||
#define FL_HIDDEN_BUTTON 3 ///< for Forms compatibility
|
||||
|
||||
extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
|
||||
|
||||
class Fl_Widget_Tracker;
|
||||
|
||||
/**
|
||||
\class Fl_Button
|
||||
\brief Buttons generate callbacks when they are clicked by the user.
|
||||
|
||||
You control exactly when and how by changing the values for type() and
|
||||
when(). Buttons can also generate callbacks in response to \c FL_SHORTCUT
|
||||
events. The button can either have an explicit shortcut(int s) value or a
|
||||
letter shortcut can be indicated in the label() with an '\&' character
|
||||
before it. For the label shortcut it does not matter if \e Alt is held
|
||||
down, but if you have an input field in the same window, the user will have
|
||||
to hold down the \e Alt key so that the input field does not eat the event
|
||||
first as an \c FL_KEYBOARD event.
|
||||
|
||||
\todo Refactor the doxygen comments for Fl_Button type() documentation.
|
||||
|
||||
For an Fl_Button object, the type() call returns one of:
|
||||
\li \c FL_NORMAL_BUTTON (0): value() remains unchanged after button press.
|
||||
\li \c FL_TOGGLE_BUTTON: value() is inverted after button press.
|
||||
\li \c FL_RADIO_BUTTON: value() is set to 1 after button press, and all other
|
||||
buttons in the current group with <tt>type() == FL_RADIO_BUTTON</tt>
|
||||
are set to zero.
|
||||
|
||||
\todo Refactor the doxygen comments for Fl_Button when() documentation.
|
||||
|
||||
For an Fl_Button object, the following when() values are useful, the default
|
||||
being \c FL_WHEN_RELEASE:
|
||||
\li \c 0: The callback is not done, instead changed() is turned on.
|
||||
\li \c FL_WHEN_RELEASE: The callback is done after the user successfully
|
||||
clicks the button, or when a shortcut is typed.
|
||||
\li \c FL_WHEN_CHANGED: The callback is done each time the value() changes
|
||||
(when the user pushes and releases the button, and as the mouse is
|
||||
dragged around in and out of the button).
|
||||
*/
|
||||
|
||||
class FL_EXPORT Fl_Button : public Fl_Widget {
|
||||
|
||||
int shortcut_;
|
||||
char value_;
|
||||
char oldval;
|
||||
uchar down_box_;
|
||||
|
||||
protected:
|
||||
|
||||
static Fl_Widget_Tracker *key_release_tracker;
|
||||
static void key_release_timeout(void*);
|
||||
void simulate_key_action();
|
||||
|
||||
virtual void draw();
|
||||
|
||||
public:
|
||||
|
||||
virtual int handle(int);
|
||||
|
||||
Fl_Button(int X, int Y, int W, int H, const char *L = 0);
|
||||
|
||||
int value(int v);
|
||||
|
||||
/**
|
||||
Returns the current value of the button (0 or 1).
|
||||
*/
|
||||
char value() const {return value_;}
|
||||
|
||||
/**
|
||||
Same as \c value(1).
|
||||
\see value(int v)
|
||||
*/
|
||||
int set() {return value(1);}
|
||||
|
||||
/**
|
||||
Same as \c value(0).
|
||||
\see value(int v)
|
||||
*/
|
||||
int clear() {return value(0);}
|
||||
|
||||
void setonly(); // this should only be called on FL_RADIO_BUTTONs
|
||||
|
||||
/**
|
||||
Returns the current shortcut key for the button.
|
||||
\retval int
|
||||
*/
|
||||
int shortcut() const {return shortcut_;}
|
||||
|
||||
/**
|
||||
Sets the shortcut key to \c s.
|
||||
Setting this overrides the use of '\&' in the label().
|
||||
The value is a bitwise OR of a key and a set of shift flags, for example:
|
||||
<tt>FL_ALT | 'a'</tt>, or
|
||||
<tt>FL_ALT | (FL_F + 10)</tt>, or just
|
||||
<tt>'a'</tt>.
|
||||
A value of 0 disables the shortcut.
|
||||
|
||||
The key can be any value returned by Fl::event_key(), but will usually be
|
||||
an ASCII letter. Use a lower-case letter unless you require the shift key
|
||||
to be held down.
|
||||
|
||||
The shift flags can be any set of values accepted by Fl::event_state().
|
||||
If the bit is on, that shift key must be pushed. Meta, Alt, Ctrl, and
|
||||
Shift must be off if they are not in the shift flags (zero for the other
|
||||
bits indicates a "don't care" setting).
|
||||
\param[in] s bitwise OR of key and shift flags
|
||||
*/
|
||||
void shortcut(int s) {shortcut_ = s;}
|
||||
|
||||
/**
|
||||
Returns the current down box type, which is drawn when value() is non-zero.
|
||||
\retval Fl_Boxtype
|
||||
*/
|
||||
Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
|
||||
|
||||
/**
|
||||
Sets the down box type. The default value of 0 causes FLTK to figure out
|
||||
the correct matching down version of box().
|
||||
|
||||
Some derived classes (e.g. Fl_Round_Button and Fl_Light_Button use
|
||||
down_box() for special purposes. See docs of these classes.
|
||||
|
||||
\param[in] b down box type
|
||||
*/
|
||||
void down_box(Fl_Boxtype b) {down_box_ = b;}
|
||||
|
||||
/// (for backwards compatibility)
|
||||
void shortcut(const char *s) {shortcut(fl_old_shortcut(s));}
|
||||
|
||||
/// (for backwards compatibility)
|
||||
Fl_Color down_color() const {return selection_color();}
|
||||
|
||||
/// (for backwards compatibility)
|
||||
void down_color(unsigned c) {selection_color(c);}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,88 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Main header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Handling transparently platform dependent cairo include files
|
||||
*/
|
||||
|
||||
#ifndef FL_CAIRO_H
|
||||
# define FL_CAIRO_H
|
||||
# ifdef FLTK_HAVE_CAIRO
|
||||
|
||||
// Cairo is currently supported for the following platforms:
|
||||
// Win32, Apple Quartz, X11
|
||||
|
||||
# include <FL/Fl_Export.H>
|
||||
|
||||
# include <cairo.h>
|
||||
|
||||
/**
|
||||
\addtogroup group_cairo
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
Contains all the necessary info on the current cairo context.
|
||||
A private internal & unique corresponding object is created to
|
||||
permit cairo context state handling while keeping it opaque.
|
||||
For internal use only.
|
||||
\note Only available when configure has the --enable-cairo option
|
||||
*/
|
||||
class FL_EXPORT Fl_Cairo_State {
|
||||
public:
|
||||
Fl_Cairo_State() : cc_(0), own_cc_(false), autolink_(false), window_(0), gc_(0) {}
|
||||
|
||||
// access attributes
|
||||
cairo_t* cc() const {return cc_;} ///< Gets the current cairo context
|
||||
bool autolink() const {return autolink_;} ///< Gets the autolink option. See Fl::cairo_autolink_context(bool)
|
||||
/** Sets the current cairo context.
|
||||
|
||||
\p own == \e true (the default) indicates that the cairo context \p c
|
||||
will be deleted by FLTK internally when another cc is set later.
|
||||
|
||||
\p own == \e false indicates cc deletion is handled externally
|
||||
by the user program.
|
||||
*/
|
||||
void cc(cairo_t* c, bool own=true) {
|
||||
if (cc_ && own_cc_) cairo_destroy(cc_);
|
||||
cc_=c;
|
||||
if (!cc_) window_=0;
|
||||
own_cc_=own;
|
||||
}
|
||||
void autolink(bool b); ///< Sets the autolink option, only available with --enable-cairoext
|
||||
void window(void* w) {window_=w;} ///< Sets the window \p w to keep track on
|
||||
void* window() const {return window_;} ///< Gets the last window attached to a cc
|
||||
void gc(void* c) {gc_=c;} ///< Sets the gc \p c to keep track on
|
||||
void* gc() const {return gc_;} ///< Gets the last gc attached to a cc
|
||||
|
||||
private:
|
||||
cairo_t * cc_; // contains the unique autoupdated cairo context
|
||||
bool own_cc_; // indicates whether we must delete the cc, useful for internal cleanup
|
||||
bool autolink_; // false by default, prevents the automatic cairo mapping on fltk windows
|
||||
// for custom cairo implementations.
|
||||
void* window_, *gc_; // for keeping track internally of last win+gc treated
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
# endif // FLTK_HAVE_CAIRO
|
||||
#endif // FL_CAIRO_H
|
||||
|
||||
//
|
||||
// End of "$Id$" .
|
||||
//
|
|
@ -1,83 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Main header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Cairo_Window Handling transparently a fltk window incorporte a cairo draw callback.
|
||||
*/
|
||||
|
||||
#ifndef FL_CAIRO_WINDOW_H
|
||||
# define FL_CAIRO_WINDOW_H
|
||||
# ifdef FLTK_HAVE_CAIRO
|
||||
|
||||
// Cairo is currently supported for the following platforms:
|
||||
// Win32, Apple Quartz, X11
|
||||
# include <FL/Fl.H>
|
||||
# include <FL/Fl_Double_Window.H>
|
||||
|
||||
/**
|
||||
\addtogroup group_cairo
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
This defines a pre-configured cairo fltk window.
|
||||
This class overloads the virtual draw() method for you,
|
||||
so that the only thing you have to do is to provide your cairo code.
|
||||
All cairo context handling is achieved transparently.
|
||||
\note You can alternatively define your custom cairo fltk window,
|
||||
and thus at least override the draw() method to provide custom cairo
|
||||
support. In this case you will probably use Fl::cairo_make_current(Fl_Window*)
|
||||
to attach a context to your window. You should do it only when your window is
|
||||
the current window. \see Fl_Window::current()
|
||||
*/
|
||||
class FL_EXPORT Fl_Cairo_Window : public Fl_Double_Window {
|
||||
|
||||
public:
|
||||
Fl_Cairo_Window(int w, int h) : Fl_Double_Window(w,h),draw_cb_(0) {}
|
||||
|
||||
protected:
|
||||
/** Overloaded to provide cairo callback support */
|
||||
void draw() {
|
||||
Fl_Double_Window::draw();
|
||||
// manual method ? if yes explicitly get a cairo_context here
|
||||
if (!Fl::cairo_autolink_context())
|
||||
Fl::cairo_make_current(this);
|
||||
if (draw_cb_) draw_cb_(this, Fl::cairo_cc());
|
||||
}
|
||||
|
||||
public:
|
||||
/** This defines the cairo draw callback prototype that you must further */
|
||||
typedef void (*cairo_draw_cb) (Fl_Cairo_Window* self, cairo_t* def);
|
||||
/**
|
||||
You must provide a draw callback which will implement your cairo rendering.
|
||||
This method will permit you to set your cairo callback to \p cb.
|
||||
*/
|
||||
void set_draw_cb(cairo_draw_cb cb){draw_cb_=cb;}
|
||||
private:
|
||||
cairo_draw_cb draw_cb_;
|
||||
};
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
# endif // FLTK_HAVE_CAIRO
|
||||
#endif // FL_CAIRO_WINDOW_H
|
||||
|
||||
//
|
||||
// End of "$Id$" .
|
||||
//
|
|
@ -1,151 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Forms chart header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Chart widget . */
|
||||
|
||||
#ifndef Fl_Chart_H
|
||||
#define Fl_Chart_H
|
||||
|
||||
#ifndef Fl_Widget_H
|
||||
#include "Fl_Widget.H"
|
||||
#endif
|
||||
|
||||
// values for type()
|
||||
#define FL_BAR_CHART 0 /**< type() for Bar Chart variant */
|
||||
#define FL_HORBAR_CHART 1 /**< type() for Horizontal Bar Chart variant */
|
||||
#define FL_LINE_CHART 2 /**< type() for Line Chart variant */
|
||||
#define FL_FILL_CHART 3 /**< type() for Fill Line Chart variant */
|
||||
#define FL_SPIKE_CHART 4 /**< type() for Spike Chart variant */
|
||||
#define FL_PIE_CHART 5 /**< type() for Pie Chart variant */
|
||||
#define FL_SPECIALPIE_CHART 6 /**< type() for Special Pie Chart variant */
|
||||
|
||||
#define FL_FILLED_CHART FL_FILL_CHART /**< for compatibility */
|
||||
|
||||
#define FL_CHART_MAX 128 /**< max entries per chart */
|
||||
#define FL_CHART_LABEL_MAX 18 /**< max label length for entry */
|
||||
|
||||
/** For internal use only */
|
||||
struct FL_CHART_ENTRY {
|
||||
float val; /**< For internal use only. */
|
||||
unsigned col; /**< For internal use only. */
|
||||
char str[FL_CHART_LABEL_MAX+1]; /**< For internal use only. */
|
||||
};
|
||||
|
||||
/**
|
||||
\class Fl_Chart
|
||||
\brief Fl_Chart displays simple charts.
|
||||
It is provided for Forms compatibility.
|
||||
|
||||
\image html charts.png
|
||||
\image latex charts.png "Fl_Chart" width=10cm
|
||||
\todo Refactor Fl_Chart::type() information.
|
||||
|
||||
The type of an Fl_Chart object can be set using type(uchar t) to:
|
||||
\li \c FL_BAR_CHART: Each sample value is drawn as a vertical bar.
|
||||
\li \c FL_FILLED_CHART: The chart is filled from the bottom of the graph
|
||||
to the sample values.
|
||||
\li \c FL_HORBAR_CHART: Each sample value is drawn as a horizontal bar.
|
||||
\li \c FL_LINE_CHART: The chart is drawn as a polyline with vertices at
|
||||
each sample value.
|
||||
\li \c FL_PIE_CHART: A pie chart is drawn with each sample value being
|
||||
drawn as a proportionate slice in the circle.
|
||||
\li \c FL_SPECIALPIE_CHART: Like \c FL_PIE_CHART, but the first slice is
|
||||
separated from the pie.
|
||||
\li \c FL_SPIKE_CHART: Each sample value is drawn as a vertical line.
|
||||
*/
|
||||
class FL_EXPORT Fl_Chart : public Fl_Widget {
|
||||
int numb;
|
||||
int maxnumb;
|
||||
int sizenumb;
|
||||
FL_CHART_ENTRY *entries;
|
||||
double min,max;
|
||||
uchar autosize_;
|
||||
Fl_Font textfont_;
|
||||
Fl_Fontsize textsize_;
|
||||
Fl_Color textcolor_;
|
||||
protected:
|
||||
void draw();
|
||||
public:
|
||||
Fl_Chart(int X, int Y, int W, int H, const char *L = 0);
|
||||
|
||||
~Fl_Chart();
|
||||
|
||||
void clear();
|
||||
|
||||
void add(double val, const char *str = 0, unsigned col = 0);
|
||||
|
||||
void insert(int ind, double val, const char *str = 0, unsigned col = 0);
|
||||
|
||||
void replace(int ind, double val, const char *str = 0, unsigned col = 0);
|
||||
|
||||
/**
|
||||
Gets the lower and upper bounds of the chart values.
|
||||
\param[out] a, b are set to lower, upper
|
||||
*/
|
||||
void bounds(double *a,double *b) const {*a = min; *b = max;}
|
||||
|
||||
void bounds(double a,double b);
|
||||
|
||||
/**
|
||||
Returns the number of data values in the chart.
|
||||
*/
|
||||
int size() const {return numb;}
|
||||
|
||||
void size(int W, int H) { Fl_Widget::size(W, H); }
|
||||
|
||||
/**
|
||||
Gets the maximum number of data values for a chart.
|
||||
*/
|
||||
int maxsize() const {return maxnumb;}
|
||||
|
||||
void maxsize(int m);
|
||||
|
||||
/** Gets the chart's text font */
|
||||
Fl_Font textfont() const {return textfont_;}
|
||||
/** Sets the chart's text font to \p s. */
|
||||
void textfont(Fl_Font s) {textfont_ = s;}
|
||||
|
||||
/** Gets the chart's text size */
|
||||
Fl_Fontsize textsize() const {return textsize_;}
|
||||
/** gets the chart's text size to \p s. */
|
||||
void textsize(Fl_Fontsize s) {textsize_ = s;}
|
||||
|
||||
/** Gets the chart's text color */
|
||||
Fl_Color textcolor() const {return textcolor_;}
|
||||
/** gets the chart's text color to \p n. */
|
||||
void textcolor(Fl_Color n) {textcolor_ = n;}
|
||||
|
||||
/**
|
||||
Get whether the chart will automatically adjust the bounds of the chart.
|
||||
\returns non-zero if auto-sizing is enabled and zero if disabled.
|
||||
*/
|
||||
uchar autosize() const {return autosize_;}
|
||||
|
||||
/**
|
||||
Set whether the chart will automatically adjust the bounds of the chart.
|
||||
\param[in] n non-zero to enable automatic resizing, zero to disable.
|
||||
*/
|
||||
void autosize(uchar n) {autosize_ = n;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,113 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Fl_Check_Browser header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Check_Browser widget . */
|
||||
|
||||
#ifndef Fl_Check_Browser_H
|
||||
#define Fl_Check_Browser_H
|
||||
|
||||
#include "Fl.H"
|
||||
#include "Fl_Browser_.H"
|
||||
|
||||
/**
|
||||
The Fl_Check_Browser widget displays a scrolling list of text
|
||||
lines that may be selected and/or checked by the user.
|
||||
*/
|
||||
class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ {
|
||||
/* required routines for Fl_Browser_ subclass: */
|
||||
|
||||
void *item_first() const;
|
||||
void *item_next(void *) const;
|
||||
void *item_prev(void *) const;
|
||||
int item_height(void *) const;
|
||||
int item_width(void *) const;
|
||||
void item_draw(void *, int, int, int, int) const;
|
||||
void item_select(void *, int);
|
||||
int item_selected(void *) const;
|
||||
|
||||
/* private data */
|
||||
|
||||
public: // IRIX 5.3 C++ compiler doesn't support private structures...
|
||||
|
||||
#ifndef FL_DOXYGEN
|
||||
/** For internal use only. */
|
||||
struct cb_item {
|
||||
cb_item *next; /**< For internal use only. */
|
||||
cb_item *prev; /**< For internal use only. */
|
||||
char checked; /**< For internal use only. */
|
||||
char selected; /**< For internal use only. */
|
||||
char *text; /**< For internal use only. */
|
||||
};
|
||||
#endif // !FL_DOXYGEN
|
||||
|
||||
private:
|
||||
|
||||
cb_item *first;
|
||||
cb_item *last;
|
||||
cb_item *cache;
|
||||
int cached_item;
|
||||
int nitems_;
|
||||
int nchecked_;
|
||||
cb_item *find_item(int) const;
|
||||
int lineno(cb_item *) const;
|
||||
|
||||
public:
|
||||
|
||||
Fl_Check_Browser(int x, int y, int w, int h, const char *l = 0);
|
||||
/** The destructor deletes all list items and destroys the browser. */
|
||||
~Fl_Check_Browser() { clear(); }
|
||||
int add(char *s); // add an (unchecked) item
|
||||
int add(char *s, int b); // add an item and set checked
|
||||
// both return the new nitems()
|
||||
int remove(int item); // delete an item. Returns nitems()
|
||||
|
||||
// inline const char * methods to avoid breaking binary compatibility...
|
||||
/** See int Fl_Check_Browser::add(char *s) */
|
||||
int add(const char *s) { return add((char *)s); }
|
||||
/** See int Fl_Check_Browser::add(char *s) */
|
||||
int add(const char *s, int b) { return add((char *)s, b); }
|
||||
|
||||
void clear(); // delete all items
|
||||
/**
|
||||
Returns how many lines are in the browser. The last line number is equal to
|
||||
this.
|
||||
*/
|
||||
int nitems() const { return nitems_; }
|
||||
/** Returns how many items are currently checked. */
|
||||
int nchecked() const { return nchecked_; }
|
||||
int checked(int item) const;
|
||||
void checked(int item, int b);
|
||||
/** Equivalent to Fl_Check_Browser::checked(item, 1). */
|
||||
void set_checked(int item) { checked(item, 1); }
|
||||
void check_all();
|
||||
void check_none();
|
||||
int value() const; // currently selected item
|
||||
char *text(int item) const; // returns pointer to internal buffer
|
||||
|
||||
protected:
|
||||
|
||||
int handle(int);
|
||||
};
|
||||
|
||||
#endif // Fl_Check_Browser_H
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Check button header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2014 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
#ifndef Fl_Check_Button_H
|
||||
#define Fl_Check_Button_H
|
||||
|
||||
#include "Fl_Light_Button.H"
|
||||
|
||||
/*
|
||||
class: Fl_Check_Button.
|
||||
|
||||
A button with a "checkmark" to show its status.
|
||||
*/
|
||||
|
||||
class FL_EXPORT Fl_Check_Button : public Fl_Light_Button {
|
||||
public:
|
||||
Fl_Check_Button(int X, int Y, int W, int H, const char *L = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,106 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Choice header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Choice widget . */
|
||||
|
||||
#ifndef Fl_Choice_H
|
||||
#define Fl_Choice_H
|
||||
|
||||
#include "Fl_Menu_.H"
|
||||
|
||||
/**
|
||||
\class Fl_Choice
|
||||
\brief A button that is used to pop up a menu.
|
||||
|
||||
This is a button that, when pushed, pops up a menu (or hierarchy of menus)
|
||||
defined by an array of Fl_Menu_Item objects.
|
||||
Motif calls this an OptionButton.
|
||||
|
||||
The only difference between this and a Fl_Menu_Button is that the name of
|
||||
the most recent chosen menu item is displayed inside the box, while the
|
||||
label is displayed outside the box. However, since the use of this is most
|
||||
often to control a single variable rather than do individual callbacks,
|
||||
some of the Fl_Menu_Button methods are redescribed here in those terms.
|
||||
|
||||
When the user clicks a menu item, value() is set to that item
|
||||
and then:
|
||||
|
||||
- The item's callback is done if one has been set; the
|
||||
Fl_Choice is passed as the Fl_Widget* argument,
|
||||
along with any userdata configured for the callback.
|
||||
|
||||
- If the item does not have a callback, the Fl_Choice widget's
|
||||
callback is done instead, along with any userdata configured
|
||||
for it. The callback can determine which item was picked using
|
||||
value(), mvalue(), item_pathname(), etc.
|
||||
|
||||
All three mouse buttons pop up the menu. The Forms behavior of the first
|
||||
two buttons to increment/decrement the choice is not implemented. This
|
||||
could be added with a subclass, however.
|
||||
|
||||
The menu will also pop up in response to shortcuts indicated by putting
|
||||
a '\&' character in the label(). See Fl_Button::shortcut(int s) for a
|
||||
description of this.
|
||||
|
||||
Typing the shortcut() of any of the items will do exactly the same as when
|
||||
you pick the item with the mouse. The '\&' character in item names are
|
||||
only looked at when the menu is popped up, however.
|
||||
|
||||
\image html choice.png
|
||||
\image latex choice.png "Fl_Choice" width=4cm
|
||||
\todo Refactor the doxygen comments for Fl_Choice changed() documentation.
|
||||
|
||||
\li <tt>int Fl_Widget::changed() const</tt>
|
||||
This value is true the user picks a different value. <em>It is turned
|
||||
off by value() and just before doing a callback (the callback can turn
|
||||
it back on if desired).</em>
|
||||
\li <tt>void Fl_Widget::set_changed()</tt>
|
||||
This method sets the changed() flag.
|
||||
\li <tt>void Fl_Widget::clear_changed()</tt>
|
||||
This method clears the changed() flag.
|
||||
\li <tt>Fl_Boxtype Fl_Choice::down_box() const</tt>
|
||||
Gets the current down box, which is used when the menu is popped up.
|
||||
The default down box type is \c FL_DOWN_BOX.
|
||||
\li <tt>void Fl_Choice::down_box(Fl_Boxtype b)</tt>
|
||||
Sets the current down box type to \p b.
|
||||
*/
|
||||
class FL_EXPORT Fl_Choice : public Fl_Menu_ {
|
||||
protected:
|
||||
void draw();
|
||||
public:
|
||||
int handle(int);
|
||||
|
||||
Fl_Choice(int X, int Y, int W, int H, const char *L = 0);
|
||||
|
||||
/**
|
||||
Gets the index of the last item chosen by the user.
|
||||
The index is zero initially.
|
||||
*/
|
||||
int value() const {return Fl_Menu_::value();}
|
||||
|
||||
int value(int v);
|
||||
|
||||
int value(const Fl_Menu_Item* v);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,128 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Clock header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Clock, Fl_Clock_Output widgets . */
|
||||
|
||||
#ifndef Fl_Clock_H
|
||||
#define Fl_Clock_H
|
||||
|
||||
#ifndef Fl_Widget_H
|
||||
#include "Fl_Widget.H"
|
||||
#endif
|
||||
|
||||
// values for type:
|
||||
#define FL_SQUARE_CLOCK 0 /**< type() of Square Clock variant */
|
||||
#define FL_ROUND_CLOCK 1 /**< type() of Round Clock variant */
|
||||
#define FL_ANALOG_CLOCK FL_SQUARE_CLOCK /**< An analog clock is square */
|
||||
#define FL_DIGITAL_CLOCK FL_SQUARE_CLOCK /**< Not yet implemented */
|
||||
|
||||
// fabien: Please keep the horizontal formatting of both images in class desc,
|
||||
// don't lose vert. space for nothing!
|
||||
|
||||
/**
|
||||
\class Fl_Clock_Output
|
||||
\brief This widget can be used to display a program-supplied time.
|
||||
|
||||
The time shown on the clock is not updated. To display the current time,
|
||||
use Fl_Clock instead.
|
||||
|
||||
\htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
|
||||
<caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
|
||||
\image html clock.png
|
||||
\htmlonly </TD> <TD> \endhtmlonly
|
||||
\image html round_clock.png
|
||||
\htmlonly </TD> </TR> </table> \endhtmlonly
|
||||
\image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
|
||||
\image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
|
||||
*/
|
||||
class FL_EXPORT Fl_Clock_Output : public Fl_Widget {
|
||||
int hour_, minute_, second_;
|
||||
ulong value_;
|
||||
void drawhands(Fl_Color,Fl_Color); // part of draw
|
||||
protected:
|
||||
void draw();
|
||||
void draw(int X, int Y, int W, int H);
|
||||
public:
|
||||
|
||||
Fl_Clock_Output(int X, int Y, int W, int H, const char *L = 0);
|
||||
|
||||
void value(ulong v); // set to this Unix time
|
||||
|
||||
void value(int H, int m, int s);
|
||||
|
||||
/**
|
||||
Returns the displayed time.
|
||||
Returns the time in seconds since the UNIX epoch (January 1, 1970).
|
||||
\see value(ulong)
|
||||
*/
|
||||
ulong value() const {return value_;}
|
||||
|
||||
/**
|
||||
Returns the displayed hour (0 to 23).
|
||||
\see value(), minute(), second()
|
||||
*/
|
||||
int hour() const {return hour_;}
|
||||
|
||||
/**
|
||||
Returns the displayed minute (0 to 59).
|
||||
\see value(), hour(), second()
|
||||
*/
|
||||
int minute() const {return minute_;}
|
||||
|
||||
/**
|
||||
Returns the displayed second (0 to 60, 60=leap second).
|
||||
\see value(), hour(), minute()
|
||||
*/
|
||||
int second() const {return second_;}
|
||||
};
|
||||
|
||||
// a Fl_Clock displays the current time always by using a timeout:
|
||||
|
||||
/**
|
||||
\class Fl_Clock
|
||||
\brief This widget provides a round analog clock display.
|
||||
|
||||
Fl_Clock is provided for Forms compatibility.
|
||||
It installs a 1-second timeout callback using Fl::add_timeout().
|
||||
You can choose the rounded or square type of the clock with type(), see below.
|
||||
\htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
|
||||
<caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
|
||||
\image html clock.png
|
||||
\htmlonly </TD> <TD> \endhtmlonly
|
||||
\image html round_clock.png
|
||||
\htmlonly </TD> </TR> </table> \endhtmlonly
|
||||
\image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
|
||||
\image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
|
||||
*/
|
||||
class FL_EXPORT Fl_Clock : public Fl_Clock_Output {
|
||||
public:
|
||||
int handle(int);
|
||||
|
||||
Fl_Clock(int X, int Y, int W, int H, const char *L = 0);
|
||||
|
||||
Fl_Clock(uchar t, int X, int Y, int W, int H, const char *L);
|
||||
|
||||
~Fl_Clock();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,190 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Color chooser header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/** \file
|
||||
Fl_Color_Chooser widget . */
|
||||
|
||||
// The color chooser object and the color chooser popup. The popup
|
||||
// is just a window containing a single color chooser and some boxes
|
||||
// to indicate the current and cancelled color.
|
||||
|
||||
#ifndef Fl_Color_Chooser_H
|
||||
#define Fl_Color_Chooser_H
|
||||
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/Fl_Return_Button.H>
|
||||
#include <FL/Fl_Choice.H>
|
||||
#include <FL/Fl_Value_Input.H>
|
||||
|
||||
#ifndef FL_DOXYGEN
|
||||
|
||||
/** For internal use only */
|
||||
class FL_EXPORT Flcc_HueBox : public Fl_Widget {
|
||||
int px, py;
|
||||
protected:
|
||||
void draw();
|
||||
int handle_key(int);
|
||||
public:
|
||||
int handle(int);
|
||||
Flcc_HueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) {
|
||||
px = py = 0;}
|
||||
};
|
||||
|
||||
/** For internal use only */
|
||||
class FL_EXPORT Flcc_ValueBox : public Fl_Widget {
|
||||
int py;
|
||||
protected:
|
||||
void draw();
|
||||
int handle_key(int);
|
||||
public:
|
||||
int handle(int);
|
||||
Flcc_ValueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) {
|
||||
py = 0;}
|
||||
};
|
||||
|
||||
/** For internal use only */
|
||||
class FL_EXPORT Flcc_Value_Input : public Fl_Value_Input {
|
||||
public:
|
||||
int format(char*);
|
||||
Flcc_Value_Input(int X, int Y, int W, int H) : Fl_Value_Input(X,Y,W,H) {}
|
||||
};
|
||||
|
||||
#endif // !FL_DOXYGEN
|
||||
|
||||
/** \addtogroup group_comdlg
|
||||
@{ */
|
||||
|
||||
/**
|
||||
\class Fl_Color_Chooser
|
||||
\brief The Fl_Color_Chooser widget provides a standard RGB color chooser.
|
||||
|
||||
\image html fl_color_chooser.jpg
|
||||
\image latex fl_color_chooser.jpg "fl_color_chooser()" width=5cm
|
||||
|
||||
You can place any number of the widgets into a panel of your own design.
|
||||
The diagram shows the widget as part of a color chooser dialog created by
|
||||
the fl_color_chooser() function. The Fl_Color_Chooser widget contains the
|
||||
hue box, value slider, and rgb input fields from the above diagram (it
|
||||
does not have the color chips or the Cancel or OK buttons).
|
||||
The callback is done every time the user changes the rgb value. It is not
|
||||
done if they move the hue control in a way that produces the \e same rgb
|
||||
value, such as when saturation or value is zero.
|
||||
|
||||
The fl_color_chooser() function pops up a window to let the user pick an
|
||||
arbitrary RGB color. They can pick the hue and saturation in the "hue box"
|
||||
on the left (hold down CTRL to just change the saturation), and the
|
||||
brightness using the vertical slider. Or they can type the 8-bit numbers
|
||||
into the RGB Fl_Value_Input fields, or drag the mouse across them to adjust
|
||||
them. The pull-down menu lets the user set the input fields to show RGB,
|
||||
HSV, or 8-bit RGB (0 to 255).
|
||||
|
||||
fl_color_chooser() returns non-zero if the user picks ok, and updates the
|
||||
RGB values. If the user picks cancel or closes the window this returns
|
||||
zero and leaves RGB unchanged.
|
||||
|
||||
If you use the color chooser on an 8-bit screen, it will allocate all the
|
||||
available colors, leaving you no space to exactly represent the color the
|
||||
user picks! You can however use fl_rectf() to fill a region with a simulated
|
||||
color using dithering.
|
||||
*/
|
||||
/** @} */
|
||||
class FL_EXPORT Fl_Color_Chooser : public Fl_Group {
|
||||
Flcc_HueBox huebox;
|
||||
Flcc_ValueBox valuebox;
|
||||
Fl_Choice choice;
|
||||
Flcc_Value_Input rvalue;
|
||||
Flcc_Value_Input gvalue;
|
||||
Flcc_Value_Input bvalue;
|
||||
Fl_Box resize_box;
|
||||
double hue_, saturation_, value_;
|
||||
double r_, g_, b_;
|
||||
void set_valuators();
|
||||
static void rgb_cb(Fl_Widget*, void*);
|
||||
static void mode_cb(Fl_Widget*, void*);
|
||||
public:
|
||||
|
||||
/**
|
||||
Returns which Fl_Color_Chooser variant is currently active
|
||||
\return color modes are rgb(0), byte(1), hex(2), or hsv(3)
|
||||
*/
|
||||
int mode() {return choice.value();}
|
||||
|
||||
/**
|
||||
Set which Fl_Color_Chooser variant is currently active
|
||||
\param[in] newMode color modes are rgb(0), byte(1), hex(2), or hsv(3)
|
||||
*/
|
||||
void mode(int newMode);
|
||||
|
||||
/**
|
||||
Returns the current hue.
|
||||
0 <= hue < 6. Zero is red, one is yellow, two is green, etc.
|
||||
<em>This value is convenient for the internal calculations - some other
|
||||
systems consider hue to run from zero to one, or from 0 to 360.</em>
|
||||
*/
|
||||
double hue() const {return hue_;}
|
||||
|
||||
/**
|
||||
Returns the saturation.
|
||||
0 <= saturation <= 1.
|
||||
*/
|
||||
double saturation() const {return saturation_;}
|
||||
|
||||
/**
|
||||
Returns the value/brightness.
|
||||
0 <= value <= 1.
|
||||
*/
|
||||
double value() const {return value_;}
|
||||
|
||||
/**
|
||||
Returns the current red value.
|
||||
0 <= r <= 1.
|
||||
*/
|
||||
double r() const {return r_;}
|
||||
|
||||
/**
|
||||
Returns the current green value.
|
||||
0 <= g <= 1.
|
||||
*/
|
||||
double g() const {return g_;}
|
||||
|
||||
/**
|
||||
Returns the current blue value.
|
||||
0 <= b <= 1.
|
||||
*/
|
||||
double b() const {return b_;}
|
||||
|
||||
int hsv(double H, double S, double V);
|
||||
|
||||
int rgb(double R, double G, double B);
|
||||
|
||||
static void hsv2rgb(double H, double S, double V, double& R, double& G, double& B);
|
||||
|
||||
static void rgb2hsv(double R, double G, double B, double& H, double& S, double& V);
|
||||
|
||||
Fl_Color_Chooser(int X, int Y, int W, int H, const char *L = 0);
|
||||
};
|
||||
|
||||
FL_EXPORT int fl_color_chooser(const char* name, double& r, double& g, double& b, int m=-1);
|
||||
FL_EXPORT int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b, int m=-1);
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,137 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Copy-to-clipboard code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2014 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
#ifndef Fl_Copy_Surface_H
|
||||
#define Fl_Copy_Surface_H
|
||||
|
||||
#include <FL/Fl_Paged_Device.H>
|
||||
#include <FL/Fl_Printer.H>
|
||||
#include <FL/x.H>
|
||||
|
||||
/** Supports copying of graphical data to the clipboard.
|
||||
|
||||
<br> After creation of an Fl_Copy_Surface object, call set_current() on it, and all subsequent graphics requests
|
||||
will be recorded in the clipboard. It's possible to draw widgets (using Fl_Copy_Surface::draw()
|
||||
) or to use any of the \ref fl_drawings or the \ref fl_attributes.
|
||||
Finally, delete the Fl_Copy_Surface object to load the clipboard with the graphical data.
|
||||
<br> Fl_GL_Window 's can be copied to the clipboard as well.
|
||||
<br> Usage example:
|
||||
\code
|
||||
Fl_Widget *g = ...; // a widget you want to copy to the clipboard
|
||||
Fl_Copy_Surface *copy_surf = new Fl_Copy_Surface(g->w(), g->h()); // create an Fl_Copy_Surface object
|
||||
copy_surf->set_current(); // direct graphics requests to the clipboard
|
||||
fl_color(FL_WHITE); fl_rectf(0, 0, g->w(), g->h()); // draw a white background
|
||||
copy_surf->draw(g); // draw the g widget in the clipboard
|
||||
delete copy_surf; // after this, the clipboard is loaded
|
||||
Fl_Display_Device::display_device()->set_current(); // direct graphics requests back to the display
|
||||
\endcode
|
||||
Platform details:
|
||||
\li MSWindows: Transparent RGB images copy without transparency.
|
||||
The graphical data are copied to the clipboard as an 'enhanced metafile'.
|
||||
\li Mac OS: The graphical data are copied to the clipboard (a.k.a. pasteboard) in two 'flavors':
|
||||
1) in vectorial form as PDF data; 2) in bitmap form as a TIFF image.
|
||||
Applications to which the clipboard content is pasted can use the flavor that suits them best.
|
||||
\li X11: the graphical data are copied to the clipboard as an image in BMP format.
|
||||
*/
|
||||
class FL_EXPORT Fl_Copy_Surface : public Fl_Surface_Device {
|
||||
private:
|
||||
int width;
|
||||
int height;
|
||||
Fl_Paged_Device *helper;
|
||||
#ifdef __APPLE__
|
||||
CFMutableDataRef pdfdata;
|
||||
CGContextRef oldgc;
|
||||
CGContextRef gc;
|
||||
void prepare_copy_pdf_and_tiff(int w, int h);
|
||||
void complete_copy_pdf_and_tiff();
|
||||
void init_PDF_context(int w, int h);
|
||||
static size_t MyPutBytes(void* info, const void* buffer, size_t count);
|
||||
#elif defined(WIN32)
|
||||
HDC oldgc;
|
||||
HDC gc;
|
||||
#else // Xlib
|
||||
Fl_Offscreen xid;
|
||||
Window oldwindow;
|
||||
Fl_Surface_Device *_ss;
|
||||
#endif
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
Fl_Copy_Surface(int w, int h);
|
||||
~Fl_Copy_Surface();
|
||||
void set_current();
|
||||
void draw(Fl_Widget* widget, int delta_x = 0, int delta_y = 0);
|
||||
void draw_decorated_window(Fl_Window* win, int delta_x = 0, int delta_y = 0);
|
||||
/** Returns the pixel width of the copy surface */
|
||||
int w() { return width; }
|
||||
/** Returns the pixel height of the copy surface */
|
||||
int h() { return height; }
|
||||
};
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
/* Mac class to reimplement Fl_Paged_Device::printable_rect() */
|
||||
class FL_EXPORT Fl_Quartz_Surface_ : public Fl_System_Printer {
|
||||
protected:
|
||||
int width;
|
||||
int height;
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
Fl_Quartz_Surface_(int w, int h);
|
||||
virtual int printable_rect(int *w, int *h);
|
||||
virtual ~Fl_Quartz_Surface_() {};
|
||||
};
|
||||
|
||||
#elif defined(WIN32)
|
||||
|
||||
/* Win class to implement translate()/untranslate() */
|
||||
class FL_EXPORT Fl_GDI_Surface_ : public Fl_Paged_Device {
|
||||
int width;
|
||||
int height;
|
||||
unsigned depth;
|
||||
POINT origins[10];
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
Fl_GDI_Surface_();
|
||||
virtual void translate(int x, int y);
|
||||
virtual void untranslate();
|
||||
virtual ~Fl_GDI_Surface_();
|
||||
};
|
||||
|
||||
#elif !defined(FL_DOXYGEN)
|
||||
|
||||
/* Xlib class to implement translate()/untranslate() */
|
||||
class FL_EXPORT Fl_Xlib_Surface_ : public Fl_Paged_Device {
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
Fl_Xlib_Surface_();
|
||||
virtual void translate(int x, int y);
|
||||
virtual void untranslate();
|
||||
virtual ~Fl_Xlib_Surface_();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // Fl_Copy_Surface_H
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,115 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Counter header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Counter widget . */
|
||||
|
||||
// A numerical value with up/down step buttons. From Forms.
|
||||
|
||||
#ifndef Fl_Counter_H
|
||||
#define Fl_Counter_H
|
||||
|
||||
#ifndef Fl_Valuator_H
|
||||
#include "Fl_Valuator.H"
|
||||
#endif
|
||||
|
||||
// values for type():
|
||||
#define FL_NORMAL_COUNTER 0 /**< type() for counter with fast buttons */
|
||||
#define FL_SIMPLE_COUNTER 1 /**< type() for counter without fast buttons */
|
||||
|
||||
/**
|
||||
Controls a single floating point value with button (or keyboard) arrows.
|
||||
Double arrows buttons achieve larger steps than simple arrows.
|
||||
\see Fl_Spinner for value input with vertical step arrows.
|
||||
<P align=center>\image html counter.png</P>
|
||||
\image latex counter.png "Fl_Counter" width=4cm
|
||||
|
||||
\todo Refactor the doxygen comments for Fl_Counter type() documentation.
|
||||
|
||||
The type of an Fl_Counter object can be set using type(uchar t) to:
|
||||
\li \c FL_NORMAL_COUNTER: Displays a counter with 4 arrow buttons.
|
||||
\li \c FL_SIMPLE_COUNTER: Displays a counter with only 2 arrow buttons.
|
||||
*/
|
||||
class FL_EXPORT Fl_Counter : public Fl_Valuator {
|
||||
|
||||
Fl_Font textfont_;
|
||||
Fl_Fontsize textsize_;
|
||||
Fl_Color textcolor_;
|
||||
double lstep_;
|
||||
uchar mouseobj;
|
||||
static void repeat_callback(void *);
|
||||
int calc_mouseobj();
|
||||
void increment_cb();
|
||||
|
||||
protected:
|
||||
|
||||
void draw();
|
||||
|
||||
public:
|
||||
|
||||
int handle(int);
|
||||
|
||||
Fl_Counter(int X, int Y, int W, int H, const char* L = 0);
|
||||
~Fl_Counter();
|
||||
|
||||
/**
|
||||
Sets the increment for the large step buttons.
|
||||
The default value is 1.0.
|
||||
\param[in] a large step increment.
|
||||
*/
|
||||
void lstep(double a) {lstep_ = a;}
|
||||
|
||||
/**
|
||||
Sets the increments for the normal and large step buttons.
|
||||
\param[in] a, b normal and large step increments.
|
||||
*/
|
||||
void step(double a,double b) {Fl_Valuator::step(a); lstep_ = b;}
|
||||
|
||||
/**
|
||||
Sets the increment for the normal step buttons.
|
||||
\param[in] a normal step increment.
|
||||
*/
|
||||
void step(double a) {Fl_Valuator::step(a);}
|
||||
|
||||
/**
|
||||
Returns the increment for normal step buttons.
|
||||
*/
|
||||
double step() const {return Fl_Valuator::step();}
|
||||
|
||||
/** Gets the text font */
|
||||
Fl_Font textfont() const {return textfont_;}
|
||||
/** Sets the text font to \p s */
|
||||
void textfont(Fl_Font s) {textfont_ = s;}
|
||||
|
||||
/** Gets the font size */
|
||||
Fl_Fontsize textsize() const {return textsize_;}
|
||||
/** Sets the font size to \p s */
|
||||
void textsize(Fl_Fontsize s) {textsize_ = s;}
|
||||
|
||||
/** Gets the font color */
|
||||
Fl_Color textcolor() const {return textcolor_;}
|
||||
/** Sets the font color to \p s */
|
||||
void textcolor(Fl_Color s) {textcolor_ = s;}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,636 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Definition of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device
|
||||
// for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2010-2014 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/** \file Fl_Device.H
|
||||
\brief declaration of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device,
|
||||
Fl_Display_Device, Fl_Device_Plugin.
|
||||
*/
|
||||
|
||||
#ifndef Fl_Device_H
|
||||
#define Fl_Device_H
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Plugin.H>
|
||||
#include <FL/Fl_Image.H>
|
||||
#include <FL/Fl_Bitmap.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
#include <FL/Fl_RGB_Image.H>
|
||||
#include <stdlib.h>
|
||||
|
||||
class Fl_Graphics_Driver;
|
||||
class Fl_Font_Descriptor;
|
||||
/** \brief Points to the driver that currently receives all graphics requests */
|
||||
FL_EXPORT extern Fl_Graphics_Driver *fl_graphics_driver;
|
||||
|
||||
/**
|
||||
signature of image generation callback function.
|
||||
\param[in] data user data passed to function
|
||||
\param[in] x,y,w position and width of scan line in image
|
||||
\param[out] buf buffer for generated image data. You must copy \p w
|
||||
pixels from scanline \p y, starting at pixel \p x
|
||||
to this buffer.
|
||||
*/
|
||||
typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf);
|
||||
|
||||
// typedef what the x,y fields in a point are:
|
||||
#ifdef WIN32
|
||||
typedef int COORD_T;
|
||||
# define XPOINT XPoint
|
||||
#elif defined(__APPLE__)
|
||||
typedef float COORD_T;
|
||||
typedef struct { float x; float y; } QPoint;
|
||||
# define XPOINT QPoint
|
||||
extern float fl_quartz_line_width_;
|
||||
#else
|
||||
typedef short COORD_T;
|
||||
# define XPOINT XPoint
|
||||
#endif
|
||||
|
||||
/**
|
||||
All graphical output devices and all graphics systems.
|
||||
This class supports a rudimentary system of run-time type information.
|
||||
*/
|
||||
class FL_EXPORT Fl_Device {
|
||||
public:
|
||||
/** A string that identifies each subclass of Fl_Device.
|
||||
Function class_name() applied to a device of this class returns this string.
|
||||
*/
|
||||
static const char *class_id;
|
||||
/**
|
||||
Returns the name of the class of this object.
|
||||
Use of the class_name() function is discouraged because it will be removed from future FLTK versions.
|
||||
|
||||
The class of an instance of an Fl_Device subclass can be checked with code such as:
|
||||
\code
|
||||
if ( instance->class_name() == Fl_Printer::class_id ) { ... }
|
||||
\endcode
|
||||
*/
|
||||
virtual const char *class_name() {return class_id;};
|
||||
/**
|
||||
Virtual destructor.
|
||||
|
||||
The destructor of Fl_Device must be virtual to make the destructors of
|
||||
derived classes being called correctly on destruction.
|
||||
*/
|
||||
virtual ~Fl_Device() {};
|
||||
};
|
||||
|
||||
#define FL_REGION_STACK_SIZE 10
|
||||
#define FL_MATRIX_STACK_SIZE 32
|
||||
/**
|
||||
\brief A virtual class subclassed for each graphics driver FLTK uses.
|
||||
Typically, FLTK applications do not use directly objects from this class. Rather, they perform
|
||||
drawing operations (e.g., fl_rectf()) that operate on the current drawing surface (see Fl_Surface_Device).
|
||||
Drawing operations are functionally presented in \ref drawing and as function lists
|
||||
in the \ref fl_drawings and \ref fl_attributes modules. The \ref fl_graphics_driver global variable
|
||||
gives at any time the graphics driver used by all drawing operations. Its value changes when
|
||||
drawing operations are directed to another drawing surface by Fl_Surface_Device::set_current().
|
||||
|
||||
\p The Fl_Graphics_Driver class is of interest if one wants to perform new kinds of drawing operations.
|
||||
An example would be to draw to a PDF file. This would involve creating a new Fl_Graphics_Driver derived
|
||||
class. This new class should implement all virtual methods of the Fl_Graphics_Driver class
|
||||
to support all FLTK drawing functions.
|
||||
*/
|
||||
class FL_EXPORT Fl_Graphics_Driver : public Fl_Device {
|
||||
public:
|
||||
/** A 2D coordinate transformation matrix
|
||||
*/
|
||||
struct matrix {double a, b, c, d, x, y;};
|
||||
private:
|
||||
static const matrix m0;
|
||||
Fl_Font font_; // current font
|
||||
Fl_Fontsize size_; // current font size
|
||||
Fl_Color color_; // current color
|
||||
int sptr;
|
||||
static const int matrix_stack_size = FL_MATRIX_STACK_SIZE;
|
||||
matrix stack[FL_MATRIX_STACK_SIZE];
|
||||
matrix m;
|
||||
int n, p_size, gap_;
|
||||
XPOINT *p;
|
||||
int what;
|
||||
int fl_clip_state_number;
|
||||
int rstackptr;
|
||||
static const int region_stack_max = FL_REGION_STACK_SIZE - 1;
|
||||
Fl_Region rstack[FL_REGION_STACK_SIZE];
|
||||
#ifdef WIN32
|
||||
int numcount;
|
||||
int counts[20];
|
||||
#endif
|
||||
Fl_Font_Descriptor *font_descriptor_;
|
||||
void transformed_vertex0(COORD_T x, COORD_T y);
|
||||
void fixloop();
|
||||
|
||||
protected:
|
||||
#ifndef FL_DOXYGEN
|
||||
enum {LINE, LOOP, POLYGON, POINT_};
|
||||
inline int vertex_no() { return n; }
|
||||
inline XPOINT *vertices() {return p;}
|
||||
inline int vertex_kind() {return what;}
|
||||
#endif
|
||||
/* ** \brief red color for background and/or mixing if device does not support masking or alpha *
|
||||
uchar bg_r_;
|
||||
** \brief green color for background and/or mixing if device does not support masking or alpha *
|
||||
uchar bg_g_;
|
||||
** \brief blue color for background and/or mixing if device does not support masking or alpha *
|
||||
uchar bg_b_; */
|
||||
friend class Fl_Pixmap;
|
||||
friend class Fl_Bitmap;
|
||||
friend class Fl_RGB_Image;
|
||||
friend void fl_rect(int x, int y, int w, int h);
|
||||
friend void fl_rectf(int x, int y, int w, int h);
|
||||
friend void fl_line_style(int style, int width, char* dashes);
|
||||
friend void fl_xyline(int x, int y, int x1);
|
||||
friend void fl_xyline(int x, int y, int x1, int y2);
|
||||
friend void fl_xyline(int x, int y, int x1, int y2, int x3);
|
||||
friend void fl_yxline(int x, int y, int y1);
|
||||
friend void fl_yxline(int x, int y, int y1, int x2);
|
||||
friend void fl_yxline(int x, int y, int y1, int x2, int y3);
|
||||
friend void fl_line(int x, int y, int x1, int y1);
|
||||
friend void fl_line(int x, int y, int x1, int y1, int x2, int y2);
|
||||
friend void fl_draw(const char *str, int n, int x, int y);
|
||||
#ifdef __APPLE__
|
||||
friend void fl_draw(const char *str, int n, float x, float y);
|
||||
#endif
|
||||
friend void fl_draw(int angle, const char *str, int n, int x, int y);
|
||||
friend void fl_rtl_draw(const char *str, int n, int x, int y);
|
||||
friend void fl_font(Fl_Font face, Fl_Fontsize size);
|
||||
friend void fl_color(Fl_Color c);
|
||||
friend void fl_color(uchar r, uchar g, uchar b);
|
||||
friend void fl_point(int x, int y);
|
||||
friend void fl_loop(int x0, int y0, int x1, int y1, int x2, int y2);
|
||||
friend void fl_loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
|
||||
friend void fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2);
|
||||
friend void fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
|
||||
friend void fl_begin_points();
|
||||
friend void fl_begin_line();
|
||||
friend void fl_begin_loop();
|
||||
friend void fl_begin_polygon();
|
||||
friend void fl_vertex(double x, double y);
|
||||
friend void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3);
|
||||
friend void fl_circle(double x, double y, double r);
|
||||
friend void fl_arc(double x, double y, double r, double start, double end);
|
||||
friend void fl_arc(int x, int y, int w, int h, double a1, double a2);
|
||||
friend void fl_pie(int x, int y, int w, int h, double a1, double a2);
|
||||
friend void fl_end_points();
|
||||
friend void fl_end_line();
|
||||
friend void fl_end_loop();
|
||||
friend void fl_end_polygon();
|
||||
friend void fl_transformed_vertex(double xf, double yf);
|
||||
friend void fl_push_clip(int x, int y, int w, int h);
|
||||
friend int fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
|
||||
friend int fl_not_clipped(int x, int y, int w, int h);
|
||||
friend void fl_push_no_clip();
|
||||
friend void fl_pop_clip();
|
||||
friend void fl_begin_complex_polygon();
|
||||
friend void fl_gap();
|
||||
friend void fl_end_complex_polygon();
|
||||
friend void fl_push_matrix();
|
||||
friend void fl_pop_matrix();
|
||||
friend void fl_mult_matrix(double a, double b, double c, double d, double x, double y);
|
||||
friend void fl_scale(double x, double y);
|
||||
friend void fl_scale(double x);
|
||||
friend void fl_translate(double x, double y);
|
||||
friend void fl_rotate(double d);
|
||||
friend double fl_transform_x(double x, double y);
|
||||
friend double fl_transform_y(double x, double y);
|
||||
friend double fl_transform_dx(double x, double y);
|
||||
friend double fl_transform_dy(double x, double y);
|
||||
friend Fl_Region fl_clip_region();
|
||||
friend void fl_clip_region(Fl_Region r);
|
||||
friend void fl_restore_clip();
|
||||
|
||||
friend void fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L);
|
||||
friend void fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L);
|
||||
friend void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D);
|
||||
friend FL_EXPORT void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D);
|
||||
friend FL_EXPORT void gl_start();
|
||||
friend FL_EXPORT void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
|
||||
matrix *fl_matrix; /**< Points to the current coordinate transformation matrix */
|
||||
|
||||
/** \brief The constructor. */
|
||||
Fl_Graphics_Driver();
|
||||
/** \brief see fl_rect(int x, int y, int w, int h). */
|
||||
virtual void rect(int x, int y, int w, int h);
|
||||
/** \brief see fl_rectf(int x, int y, int w, int h). */
|
||||
virtual void rectf(int x, int y, int w, int h);
|
||||
/** \brief see fl_line_style(int style, int width, char* dashes). */
|
||||
virtual void line_style(int style, int width=0, char* dashes=0);
|
||||
/** \brief see fl_xyline(int x, int y, int x1). */
|
||||
virtual void xyline(int x, int y, int x1);
|
||||
/** \brief see fl_xyline(int x, int y, int x1, int y2). */
|
||||
virtual void xyline(int x, int y, int x1, int y2);
|
||||
/** \brief see fl_xyline(int x, int y, int x1, int y2, int x3). */
|
||||
virtual void xyline(int x, int y, int x1, int y2, int x3);
|
||||
/** \brief see fl_yxline(int x, int y, int y1). */
|
||||
virtual void yxline(int x, int y, int y1);
|
||||
/** \brief see fl_yxline(int x, int y, int y1, int x2). */
|
||||
virtual void yxline(int x, int y, int y1, int x2);
|
||||
/** \brief see fl_yxline(int x, int y, int y1, int x2, int y3). */
|
||||
virtual void yxline(int x, int y, int y1, int x2, int y3);
|
||||
/** \brief see fl_line(int x, int y, int x1, int y1). */
|
||||
virtual void line(int x, int y, int x1, int y1);
|
||||
/** \brief see fl_line(int x, int y, int x1, int y1, int x2, int y2). */
|
||||
virtual void line(int x, int y, int x1, int y1, int x2, int y2);
|
||||
/** \brief see fl_draw(const char *str, int n, int x, int y). */
|
||||
virtual void draw(const char *str, int n, int x, int y) {}
|
||||
#ifdef __APPLE__
|
||||
virtual void draw(const char *str, int n, float x, float y) { draw(str, n, (int)(x+0.5), (int)(y+0.5));}
|
||||
#endif
|
||||
/** \brief see fl_draw(int angle, const char *str, int n, int x, int y). */
|
||||
virtual void draw(int angle, const char *str, int n, int x, int y) {}
|
||||
/** \brief see fl_rtl_draw(const char *str, int n, int x, int y). */
|
||||
virtual void rtl_draw(const char *str, int n, int x, int y) {};
|
||||
/** \brief see fl_color(Fl_Color c). */
|
||||
virtual void color(Fl_Color c) {color_ = c;}
|
||||
/** \brief see fl_color(uchar r, uchar g, uchar b). */
|
||||
virtual void color(uchar r, uchar g, uchar b) {}
|
||||
/** \brief see fl_point(int x, int y). */
|
||||
virtual void point(int x, int y);
|
||||
/** \brief see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2). */
|
||||
virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2);
|
||||
/** \brief see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3). */
|
||||
virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
|
||||
/** \brief see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2). */
|
||||
virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
|
||||
/** \brief see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3). */
|
||||
virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
|
||||
/** \brief see fl_begin_points(). */
|
||||
virtual void begin_points();
|
||||
/** \brief see fl_begin_line(). */
|
||||
virtual void begin_line();
|
||||
/** \brief see fl_begin_loop(). */
|
||||
virtual void begin_loop();
|
||||
/** \brief see fl_begin_polygon(). */
|
||||
virtual void begin_polygon();
|
||||
/** \brief see fl_vertex(double x, double y). */
|
||||
virtual void vertex(double x, double y);
|
||||
/** \brief see fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3). */
|
||||
virtual void curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3);
|
||||
/** \brief see fl_circle(double x, double y, double r). */
|
||||
virtual void circle(double x, double y, double r);
|
||||
/** \brief see fl_arc(double x, double y, double r, double start, double end). */
|
||||
virtual void arc(double x, double y, double r, double start, double end);
|
||||
/** \brief see fl_arc(int x, int y, int w, int h, double a1, double a2). */
|
||||
virtual void arc(int x, int y, int w, int h, double a1, double a2);
|
||||
/** \brief see fl_pie(int x, int y, int w, int h, double a1, double a2). */
|
||||
virtual void pie(int x, int y, int w, int h, double a1, double a2);
|
||||
/** \brief see fl_end_points(). */
|
||||
virtual void end_points();
|
||||
/** \brief see fl_end_line(). */
|
||||
virtual void end_line();
|
||||
/** \brief see fl_end_loop(). */
|
||||
virtual void end_loop();
|
||||
/** \brief see fl_end_polygon(). */
|
||||
virtual void end_polygon();
|
||||
/** \brief see fl_begin_complex_polygon(). */
|
||||
virtual void begin_complex_polygon();
|
||||
/** \brief see fl_gap(). */
|
||||
virtual void gap();
|
||||
/** \brief see fl_end_complex_polygon(). */
|
||||
virtual void end_complex_polygon();
|
||||
/** \brief see fl_transformed_vertex(double xf, double yf). */
|
||||
virtual void transformed_vertex(double xf, double yf);
|
||||
/** \brief see fl_push_clip(int x, int y, int w, int h). */
|
||||
virtual void push_clip(int x, int y, int w, int h);
|
||||
/** \brief see fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H). */
|
||||
virtual int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
|
||||
/** \brief see fl_not_clipped(int x, int y, int w, int h). */
|
||||
virtual int not_clipped(int x, int y, int w, int h);
|
||||
/** \brief see fl_push_no_clip(). */
|
||||
virtual void push_no_clip();
|
||||
/** \brief see fl_pop_clip(). */
|
||||
virtual void pop_clip();
|
||||
|
||||
/** \brief see fl_push_matrix(). */
|
||||
void push_matrix();
|
||||
/** \brief see fl_pop_matrix(). */
|
||||
void pop_matrix();
|
||||
/** \brief see fl_mult_matrix(double a, double b, double c, double d, double x, double y). */
|
||||
void mult_matrix(double a, double b, double c, double d, double x, double y);
|
||||
/** \brief see fl_scale(double x, double y). */
|
||||
inline void scale(double x, double y) { mult_matrix(x,0,0,y,0,0); }
|
||||
/** \brief see fl_scale(double x). */
|
||||
inline void scale(double x) { mult_matrix(x,0,0,x,0,0); }
|
||||
/** \brief see fl_translate(double x, double y). */
|
||||
inline void translate(double x,double y) { mult_matrix(1,0,0,1,x,y); }
|
||||
/** \brief see fl_rotate(double d). */
|
||||
void rotate(double d);
|
||||
/** \brief see fl_transform_x(double x, double y). */
|
||||
double transform_x(double x, double y);
|
||||
/** \brief see fl_transform_y(double x, double y). */
|
||||
double transform_y(double x, double y);
|
||||
/** \brief see fl_transform_dx(double x, double y). */
|
||||
double transform_dx(double x, double y);
|
||||
/** \brief see fl_transform_dy(double x, double y). */
|
||||
double transform_dy(double x, double y);
|
||||
/** \brief see fl_clip_region(). */
|
||||
Fl_Region clip_region();
|
||||
/** \brief see fl_clip_region(Fl_Region r). */
|
||||
void clip_region(Fl_Region r);
|
||||
/** \brief see fl_restore_clip(). */
|
||||
void restore_clip();
|
||||
|
||||
// Images
|
||||
/** \brief see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L). */
|
||||
virtual void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) {}
|
||||
/** \brief see fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L). */
|
||||
virtual void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) {}
|
||||
/** \brief see fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D). */
|
||||
virtual void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3) {}
|
||||
/** \brief see fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D). */
|
||||
virtual void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1) {}
|
||||
// Image classes
|
||||
/** \brief Draws an Fl_RGB_Image object to the device.
|
||||
*
|
||||
Specifies a bounding box for the image, with the origin (upper left-hand corner) of
|
||||
the image offset by the cx and cy arguments.
|
||||
*/
|
||||
virtual void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy) {}
|
||||
/** \brief Draws an Fl_Pixmap object to the device.
|
||||
*
|
||||
Specifies a bounding box for the image, with the origin (upper left-hand corner) of
|
||||
the image offset by the cx and cy arguments.
|
||||
*/
|
||||
virtual void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy) {}
|
||||
/** \brief Draws an Fl_Bitmap object to the device.
|
||||
*
|
||||
Specifies a bounding box for the image, with the origin (upper left-hand corner) of
|
||||
the image offset by the cx and cy arguments.
|
||||
*/
|
||||
virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {}
|
||||
#if FLTK_ABI_VERSION >= 10301
|
||||
virtual
|
||||
#endif
|
||||
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
|
||||
|
||||
public:
|
||||
static const char *class_id;
|
||||
virtual const char *class_name() {return class_id;};
|
||||
/** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */
|
||||
virtual void font(Fl_Font face, Fl_Fontsize fsize) {font_ = face; size_ = fsize;}
|
||||
/** \brief see fl_font(void). */
|
||||
Fl_Font font() {return font_; }
|
||||
/** \brief see fl_size(). */
|
||||
Fl_Fontsize size() {return size_; }
|
||||
/** \brief see fl_width(const char *str, int n). */
|
||||
virtual double width(const char *str, int n) {return 0;}
|
||||
/** \brief see fl_width(unsigned int n). */
|
||||
virtual inline double width(unsigned int c) { char ch = (char)c; return width(&ch, 1); }
|
||||
/** \brief see fl_text_extents(const char*, int n, int& dx, int& dy, int& w, int& h). */
|
||||
virtual void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
|
||||
/** \brief see fl_height(). */
|
||||
virtual int height() {return size();}
|
||||
/** \brief see fl_descent(). */
|
||||
virtual int descent() {return 0;}
|
||||
/** \brief see fl_color(void). */
|
||||
Fl_Color color() {return color_;}
|
||||
/** Returns a pointer to the current Fl_Font_Descriptor for the graphics driver */
|
||||
inline Fl_Font_Descriptor *font_descriptor() { return font_descriptor_;}
|
||||
/** Sets the current Fl_Font_Descriptor for the graphics driver */
|
||||
inline void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;}
|
||||
#if FLTK_ABI_VERSION >= 10304 || defined(FL_DOXYGEN)
|
||||
virtual
|
||||
#endif
|
||||
int draw_scaled(Fl_Image *img, int X, int Y, int W, int H);
|
||||
/** \brief The destructor */
|
||||
virtual ~Fl_Graphics_Driver() { if (p) free(p); }
|
||||
};
|
||||
|
||||
#if defined(__APPLE__) || defined(FL_DOXYGEN)
|
||||
/**
|
||||
\brief The Mac OS X-specific graphics class.
|
||||
*
|
||||
This class is implemented only on the Mac OS X platform.
|
||||
*/
|
||||
class FL_EXPORT Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver {
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
void color(Fl_Color c);
|
||||
void color(uchar r, uchar g, uchar b);
|
||||
void draw(const char* str, int n, int x, int y);
|
||||
#ifdef __APPLE__
|
||||
void draw(const char *str, int n, float x, float y);
|
||||
#endif
|
||||
void draw(int angle, const char *str, int n, int x, int y);
|
||||
void rtl_draw(const char* str, int n, int x, int y);
|
||||
void font(Fl_Font face, Fl_Fontsize size);
|
||||
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP);
|
||||
void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0);
|
||||
void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
|
||||
void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
|
||||
void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
|
||||
double width(const char *str, int n);
|
||||
double width(unsigned int c);
|
||||
void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
|
||||
int height();
|
||||
int descent();
|
||||
#if ! defined(FL_DOXYGEN)
|
||||
static Fl_Offscreen create_offscreen_with_alpha(int w, int h);
|
||||
#endif
|
||||
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
|
||||
};
|
||||
#endif
|
||||
#if defined(WIN32) || defined(FL_DOXYGEN)
|
||||
/**
|
||||
\brief The MSWindows-specific graphics class.
|
||||
*
|
||||
This class is implemented only on the MSWindows platform.
|
||||
*/
|
||||
class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver {
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
void color(Fl_Color c);
|
||||
void color(uchar r, uchar g, uchar b);
|
||||
void draw(const char* str, int n, int x, int y);
|
||||
void draw(int angle, const char *str, int n, int x, int y);
|
||||
void rtl_draw(const char* str, int n, int x, int y);
|
||||
void font(Fl_Font face, Fl_Fontsize size);
|
||||
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0);
|
||||
void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
|
||||
void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
|
||||
void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
|
||||
double width(const char *str, int n);
|
||||
double width(unsigned int c);
|
||||
void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
|
||||
int height();
|
||||
int descent();
|
||||
#if ! defined(FL_DOXYGEN)
|
||||
void copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy);
|
||||
#endif
|
||||
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
|
||||
};
|
||||
|
||||
/**
|
||||
The graphics driver used when printing on MSWindows.
|
||||
*
|
||||
This class is implemented only on the MSWindows platform. It 's extremely similar to Fl_GDI_Graphics_Driver.
|
||||
*/
|
||||
class FL_EXPORT Fl_GDI_Printer_Graphics_Driver : public Fl_GDI_Graphics_Driver {
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP);
|
||||
};
|
||||
#endif
|
||||
#if !(defined(__APPLE__) || defined(WIN32))
|
||||
/**
|
||||
\brief The Xlib-specific graphics class.
|
||||
*
|
||||
This class is implemented only on the Xlib platform.
|
||||
*/
|
||||
class FL_EXPORT Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver {
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
void color(Fl_Color c);
|
||||
void color(uchar r, uchar g, uchar b);
|
||||
void draw(const char* str, int n, int x, int y);
|
||||
void draw(int angle, const char *str, int n, int x, int y);
|
||||
void rtl_draw(const char* str, int n, int x, int y);
|
||||
void font(Fl_Font face, Fl_Fontsize size);
|
||||
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0);
|
||||
void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
|
||||
void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
|
||||
void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
|
||||
double width(const char *str, int n);
|
||||
double width(unsigned int c);
|
||||
void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
|
||||
int height();
|
||||
int descent();
|
||||
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
|
||||
#if ! defined(FL_DOXYGEN)
|
||||
void copy_offscreen_with_alpha(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
A drawing surface that's susceptible to receive graphical output.
|
||||
Any FLTK application has at any time a current drawing surface to which all drawing requests are directed.
|
||||
The current surface is given by Fl_Surface_Device::surface().
|
||||
When main() begins running, the current drawing surface has been set to the computer's display,
|
||||
an instance of the Fl_Display_Device class.
|
||||
|
||||
A drawing surface other than the computer's display, is typically used as follows:
|
||||
<ol><li> Create \c surface, an object from a particular Fl_Surface_Device derived class (e.g., Fl_Copy_Surface, Fl_Printer).
|
||||
<li> Memorize what is the current drawing surface with <tt> Fl_Surface_Device *old_current = Fl_Surface_Device::surface();</tt>
|
||||
<li> Call \c surface->set_current(); to redirect all graphics requests to \c surface which becomes the new
|
||||
current drawing surface (not necessary with class Fl_Printer because it is done by Fl_Printer::start_job()).
|
||||
<li> At this point any of the \ref fl_drawings (e.g., fl_rect()) or the \ref fl_attributes or \ref drawing_images functions
|
||||
(e.g., fl_draw_image(), Fl_Image::draw()) operates on the new current drawing surface.
|
||||
Certain drawing surfaces allow additional ways to draw to them (e.g., Fl_Printer::print_widget(), Fl_Image_Surface::draw()).
|
||||
<li> After all drawing requests have been performed, redirect graphics requests back to their previous destination
|
||||
with \c old_current->set_current();.
|
||||
<li> Delete \c surface.
|
||||
</ol>
|
||||
*/
|
||||
class FL_EXPORT Fl_Surface_Device : public Fl_Device {
|
||||
/** \brief The graphics driver in use by this surface. */
|
||||
Fl_Graphics_Driver *_driver;
|
||||
static Fl_Surface_Device *_surface; // the surface that currently receives graphics output
|
||||
static Fl_Surface_Device *default_surface(); // create surface is none exists yet
|
||||
protected:
|
||||
/** \brief Constructor that sets the graphics driver to use for the created surface. */
|
||||
Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver; };
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
virtual void set_current(void);
|
||||
/** \brief Sets the graphics driver of this drawing surface. */
|
||||
inline void driver(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver;};
|
||||
/** \brief Returns the graphics driver of this drawing surface. */
|
||||
inline Fl_Graphics_Driver *driver() {return _driver; };
|
||||
/** The current drawing surface.
|
||||
In other words, the Fl_Surface_Device object that currently receives all graphics output */
|
||||
static inline Fl_Surface_Device *surface() {
|
||||
return _surface ? _surface : default_surface();
|
||||
};
|
||||
/** \brief The destructor. */
|
||||
virtual ~Fl_Surface_Device() {}
|
||||
};
|
||||
|
||||
/**
|
||||
A display to which the computer can draw.
|
||||
When the program begins running, an Fl_Display_Device instance has been created and made the current drawing surface.
|
||||
There is no need to create any other object of this class.
|
||||
*/
|
||||
class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device {
|
||||
static Fl_Display_Device *_display; // the platform display device
|
||||
#ifdef __APPLE__
|
||||
friend class Fl_X;
|
||||
friend class Fl_Graphics_Driver;
|
||||
static bool high_res_window_; //< true when drawing to a window of a retina display (Mac OS X only)
|
||||
static bool high_resolution() {return high_res_window_;}
|
||||
#endif
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
Fl_Display_Device(Fl_Graphics_Driver *graphics_driver);
|
||||
static Fl_Display_Device *display_device();
|
||||
};
|
||||
|
||||
/**
|
||||
This plugin socket allows the integration of new device drivers for special
|
||||
window or screen types.
|
||||
This class is not intended for use outside the FLTK library.
|
||||
It is currently used to provide an automated printing
|
||||
service and screen capture for OpenGL windows, if linked with fltk_gl.
|
||||
*/
|
||||
class FL_EXPORT Fl_Device_Plugin : public Fl_Plugin {
|
||||
public:
|
||||
/** \brief The constructor */
|
||||
Fl_Device_Plugin(const char *pluginName)
|
||||
: Fl_Plugin(klass(), pluginName) { }
|
||||
/** \brief Returns the class name */
|
||||
virtual const char *klass() { return "fltk:device"; }
|
||||
/** \brief Returns the plugin name */
|
||||
virtual const char *name() = 0;
|
||||
/** \brief Prints a widget
|
||||
\param w the widget
|
||||
\param x,y offsets where to print relatively to coordinates origin
|
||||
\param height height of the current drawing area
|
||||
*/
|
||||
virtual int print(Fl_Widget* w, int x, int y, int height) = 0;
|
||||
/** captures a rectangle of a widget as an image
|
||||
\return The captured pixels as an RGB image
|
||||
*/
|
||||
#ifdef FL_LIBRARY
|
||||
virtual
|
||||
#endif
|
||||
Fl_RGB_Image* rectangle_capture(Fl_Widget *widget, int x, int y, int w, int h) {return NULL;}
|
||||
};
|
||||
|
||||
#endif // Fl_Device_H
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,88 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Dial header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Dial widget . */
|
||||
|
||||
#ifndef Fl_Dial_H
|
||||
#define Fl_Dial_H
|
||||
|
||||
#ifndef Fl_Valuator_H
|
||||
#include "Fl_Valuator.H"
|
||||
#endif
|
||||
|
||||
// values for type():
|
||||
#define FL_NORMAL_DIAL 0 /**< type() for dial variant with dot */
|
||||
#define FL_LINE_DIAL 1 /**< type() for dial variant with line */
|
||||
#define FL_FILL_DIAL 2 /**< type() for dial variant with filled arc */
|
||||
|
||||
/**
|
||||
The Fl_Dial widget provides a circular dial to control a
|
||||
single floating point value.
|
||||
<P ALIGN=CENTER>\image html dial.png
|
||||
\image latex dial.png "Fl_Dial" width=4cm
|
||||
Use type() to set the type of the dial to:
|
||||
<UL>
|
||||
<LI>FL_NORMAL_DIAL - Draws a normal dial with a knob. </LI>
|
||||
<LI>FL_LINE_DIAL - Draws a dial with a line. </LI>
|
||||
<LI>FL_FILL_DIAL - Draws a dial with a filled arc. </LI>
|
||||
</UL>
|
||||
|
||||
*/
|
||||
class FL_EXPORT Fl_Dial : public Fl_Valuator {
|
||||
|
||||
short a1,a2;
|
||||
|
||||
protected:
|
||||
|
||||
// these allow subclasses to put the dial in a smaller area:
|
||||
void draw(int X, int Y, int W, int H);
|
||||
int handle(int event, int X, int Y, int W, int H);
|
||||
void draw();
|
||||
|
||||
public:
|
||||
|
||||
int handle(int);
|
||||
/**
|
||||
Creates a new Fl_Dial widget using the given position, size,
|
||||
and label string. The default type is FL_NORMAL_DIAL.
|
||||
*/
|
||||
Fl_Dial(int x,int y,int w,int h, const char *l = 0);
|
||||
/**
|
||||
Sets Or gets the angles used for the minimum and maximum values. The default
|
||||
values are 45 and 315 (0 degrees is straight down and the angles
|
||||
progress clockwise). Normally angle1 is less than angle2, but if you
|
||||
reverse them the dial moves counter-clockwise.
|
||||
*/
|
||||
short angle1() const {return a1;}
|
||||
/** See short angle1() const */
|
||||
void angle1(short a) {a1 = a;}
|
||||
/** See short angle1() const */
|
||||
short angle2() const {return a2;}
|
||||
/** See short angle1() const */
|
||||
void angle2(short a) {a2 = a;}
|
||||
/** See short angle1() const */
|
||||
void angles(short a, short b) {a1 = a; a2 = b;}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,73 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Double-buffered window header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Double_Window widget . */
|
||||
|
||||
#ifndef Fl_Double_Window_H
|
||||
#define Fl_Double_Window_H
|
||||
|
||||
#include "Fl_Window.H"
|
||||
|
||||
/**
|
||||
The Fl_Double_Window provides a double-buffered window.
|
||||
If possible this will use the X double buffering extension (Xdbe). If
|
||||
not, it will draw the window data into an off-screen pixmap, and then
|
||||
copy it to the on-screen window.
|
||||
<P>It is highly recommended that you put the following code before the
|
||||
first show() of <I>any</I> window in your program: </P>
|
||||
\code
|
||||
Fl::visual(FL_DOUBLE|FL_INDEX)
|
||||
\endcode
|
||||
This makes sure you can use Xdbe on servers where double buffering
|
||||
does not exist for every visual.
|
||||
*/
|
||||
class FL_EXPORT Fl_Double_Window : public Fl_Window {
|
||||
protected:
|
||||
void flush(int eraseoverlay);
|
||||
/**
|
||||
Force double buffering, even if the OS already buffers windows
|
||||
(overlays need that on MacOS and Windows2000)
|
||||
*/
|
||||
char force_doublebuffering_;
|
||||
public:
|
||||
void show();
|
||||
void show(int a, char **b) {Fl_Window::show(a,b);}
|
||||
void flush();
|
||||
void resize(int,int,int,int);
|
||||
void hide();
|
||||
~Fl_Double_Window();
|
||||
|
||||
/**
|
||||
Creates a new Fl_Double_Window widget using the given
|
||||
position, size, and label (title) string.
|
||||
*/
|
||||
Fl_Double_Window(int W, int H, const char *l = 0);
|
||||
|
||||
/**
|
||||
See Fl_Double_Window::Fl_Double_Window(int w, int h, const char *label = 0)
|
||||
*/
|
||||
Fl_Double_Window(int X, int Y, int W, int H, const char *l = 0);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* WIN32 DLL export .
|
||||
*
|
||||
* Copyright 1998-2010 by Bill Spitzak and others.
|
||||
*
|
||||
* This library is free software. Distribution and use rights are outlined in
|
||||
* the file "COPYING" which should have been included with this file. If this
|
||||
* file is missing or damaged, see the license at:
|
||||
*
|
||||
* http://www.fltk.org/COPYING.php
|
||||
*
|
||||
* Please report all bugs and problems on the following page:
|
||||
*
|
||||
* http://www.fltk.org/str.php
|
||||
*/
|
||||
|
||||
#ifndef Fl_Export_H
|
||||
# define Fl_Export_H
|
||||
|
||||
/*
|
||||
* The following is only used when building DLLs under WIN32...
|
||||
*/
|
||||
|
||||
# if defined(FL_DLL)
|
||||
# ifdef FL_LIBRARY
|
||||
# define FL_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define FL_EXPORT __declspec(dllimport)
|
||||
# endif /* FL_LIBRARY */
|
||||
# elif __GNUC__ >= 4
|
||||
# define FL_EXPORT __attribute__ ((visibility ("default")))
|
||||
# else
|
||||
# define FL_EXPORT
|
||||
# endif /* FL_DLL */
|
||||
|
||||
#endif /* !Fl_Export_H */
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
|
@ -1,111 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// FileBrowser definitions.
|
||||
//
|
||||
// Copyright 1999-2010 by Michael Sweet.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_File_Browser widget . */
|
||||
|
||||
//
|
||||
// Include necessary header files...
|
||||
//
|
||||
|
||||
#ifndef _Fl_File_Browser_H_
|
||||
# define _Fl_File_Browser_H_
|
||||
|
||||
# include "Fl_Browser.H"
|
||||
# include "Fl_File_Icon.H"
|
||||
# include "filename.H"
|
||||
|
||||
|
||||
//
|
||||
// Fl_File_Browser class...
|
||||
//
|
||||
|
||||
/** The Fl_File_Browser widget displays a list of filenames, optionally with file-specific icons. */
|
||||
class FL_EXPORT Fl_File_Browser : public Fl_Browser {
|
||||
|
||||
int filetype_;
|
||||
const char *directory_;
|
||||
uchar iconsize_;
|
||||
const char *pattern_;
|
||||
|
||||
int full_height() const;
|
||||
int item_height(void *) const;
|
||||
int item_width(void *) const;
|
||||
void item_draw(void *, int, int, int, int) const;
|
||||
int incr_height() const { return (item_height(0)); }
|
||||
|
||||
public:
|
||||
enum { FILES, DIRECTORIES };
|
||||
|
||||
/**
|
||||
The constructor creates the Fl_File_Browser widget at the specified position and size.
|
||||
The destructor destroys the widget and frees all memory that has been allocated.
|
||||
*/
|
||||
Fl_File_Browser(int, int, int, int, const char * = 0);
|
||||
|
||||
/** Sets or gets the size of the icons. The default size is 20 pixels. */
|
||||
uchar iconsize() const { return (iconsize_); };
|
||||
/** Sets or gets the size of the icons. The default size is 20 pixels. */
|
||||
void iconsize(uchar s) { iconsize_ = s; redraw(); };
|
||||
|
||||
/**
|
||||
Sets or gets the filename filter. The pattern matching uses
|
||||
the fl_filename_match()
|
||||
function in FLTK.
|
||||
*/
|
||||
void filter(const char *pattern);
|
||||
/**
|
||||
Sets or gets the filename filter. The pattern matching uses
|
||||
the fl_filename_match()
|
||||
function in FLTK.
|
||||
*/
|
||||
const char *filter() const { return (pattern_); };
|
||||
|
||||
/**
|
||||
Loads the specified directory into the browser. If icons have been
|
||||
loaded then the correct icon is associated with each file in the list.
|
||||
|
||||
<P>The sort argument specifies a sort function to be used with
|
||||
fl_filename_list().
|
||||
*/
|
||||
int load(const char *directory, Fl_File_Sort_F *sort = fl_numericsort);
|
||||
|
||||
Fl_Fontsize textsize() const { return Fl_Browser::textsize(); };
|
||||
void textsize(Fl_Fontsize s) { Fl_Browser::textsize(s); iconsize_ = (uchar)(3 * s / 2); };
|
||||
|
||||
/**
|
||||
Sets or gets the file browser type, FILES or
|
||||
DIRECTORIES. When set to FILES, both
|
||||
files and directories are shown. Otherwise only directories are
|
||||
shown.
|
||||
*/
|
||||
int filetype() const { return (filetype_); };
|
||||
/**
|
||||
Sets or gets the file browser type, FILES or
|
||||
DIRECTORIES. When set to FILES, both
|
||||
files and directories are shown. Otherwise only directories are
|
||||
shown.
|
||||
*/
|
||||
void filetype(int t) { filetype_ = t; };
|
||||
};
|
||||
|
||||
#endif // !_Fl_File_Browser_H_
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,245 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Fl_File_Chooser dialog for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2015 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
// =======================================================================
|
||||
// DO NOT EDIT FL/Fl_File_Chooser.H and src/Fl_File_Chooser.cxx !!!
|
||||
// =======================================================================
|
||||
// Please use fluid to change src/Fl_File_Chooser.fl interactively
|
||||
// and then use fluid to "write code" or edit and use fluid -c .
|
||||
// =======================================================================
|
||||
//
|
||||
|
||||
// generated by Fast Light User Interface Designer (fluid) version 1.0305
|
||||
|
||||
#ifndef Fl_File_Chooser_H
|
||||
#define Fl_File_Chooser_H
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Choice.H>
|
||||
#include <FL/Fl_Menu_Button.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Preferences.H>
|
||||
#include <FL/Fl_Tile.H>
|
||||
#include <FL/Fl_File_Browser.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/Fl_Check_Button.H>
|
||||
#include <FL/Fl_File_Input.H>
|
||||
#include <FL/Fl_Return_Button.H>
|
||||
#include <FL/fl_ask.H>
|
||||
|
||||
class FL_EXPORT Fl_File_Chooser {
|
||||
public:
|
||||
enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };
|
||||
private:
|
||||
static Fl_Preferences *prefs_;
|
||||
void (*callback_)(Fl_File_Chooser*, void *);
|
||||
void *data_;
|
||||
char directory_[FL_PATH_MAX];
|
||||
char pattern_[FL_PATH_MAX];
|
||||
char preview_text_[2048];
|
||||
int type_;
|
||||
void favoritesButtonCB();
|
||||
void favoritesCB(Fl_Widget *w);
|
||||
void fileListCB();
|
||||
void fileNameCB();
|
||||
void newdir();
|
||||
static void previewCB(Fl_File_Chooser *fc);
|
||||
void showChoiceCB();
|
||||
void update_favorites();
|
||||
void update_preview();
|
||||
public:
|
||||
Fl_File_Chooser(const char *d, const char *p, int t, const char *title);
|
||||
private:
|
||||
Fl_Double_Window *window;
|
||||
inline void cb_window_i(Fl_Double_Window*, void*);
|
||||
static void cb_window(Fl_Double_Window*, void*);
|
||||
Fl_Choice *showChoice;
|
||||
inline void cb_showChoice_i(Fl_Choice*, void*);
|
||||
static void cb_showChoice(Fl_Choice*, void*);
|
||||
Fl_Menu_Button *favoritesButton;
|
||||
inline void cb_favoritesButton_i(Fl_Menu_Button*, void*);
|
||||
static void cb_favoritesButton(Fl_Menu_Button*, void*);
|
||||
public:
|
||||
Fl_Button *newButton;
|
||||
private:
|
||||
inline void cb_newButton_i(Fl_Button*, void*);
|
||||
static void cb_newButton(Fl_Button*, void*);
|
||||
inline void cb__i(Fl_Tile*, void*);
|
||||
static void cb_(Fl_Tile*, void*);
|
||||
Fl_File_Browser *fileList;
|
||||
inline void cb_fileList_i(Fl_File_Browser*, void*);
|
||||
static void cb_fileList(Fl_File_Browser*, void*);
|
||||
Fl_Box *previewBox;
|
||||
public:
|
||||
Fl_Check_Button *previewButton;
|
||||
private:
|
||||
inline void cb_previewButton_i(Fl_Check_Button*, void*);
|
||||
static void cb_previewButton(Fl_Check_Button*, void*);
|
||||
public:
|
||||
Fl_Check_Button *showHiddenButton;
|
||||
private:
|
||||
inline void cb_showHiddenButton_i(Fl_Check_Button*, void*);
|
||||
static void cb_showHiddenButton(Fl_Check_Button*, void*);
|
||||
Fl_File_Input *fileName;
|
||||
inline void cb_fileName_i(Fl_File_Input*, void*);
|
||||
static void cb_fileName(Fl_File_Input*, void*);
|
||||
Fl_Return_Button *okButton;
|
||||
inline void cb_okButton_i(Fl_Return_Button*, void*);
|
||||
static void cb_okButton(Fl_Return_Button*, void*);
|
||||
Fl_Button *cancelButton;
|
||||
inline void cb_cancelButton_i(Fl_Button*, void*);
|
||||
static void cb_cancelButton(Fl_Button*, void*);
|
||||
Fl_Double_Window *favWindow;
|
||||
Fl_File_Browser *favList;
|
||||
inline void cb_favList_i(Fl_File_Browser*, void*);
|
||||
static void cb_favList(Fl_File_Browser*, void*);
|
||||
Fl_Button *favUpButton;
|
||||
inline void cb_favUpButton_i(Fl_Button*, void*);
|
||||
static void cb_favUpButton(Fl_Button*, void*);
|
||||
Fl_Button *favDeleteButton;
|
||||
inline void cb_favDeleteButton_i(Fl_Button*, void*);
|
||||
static void cb_favDeleteButton(Fl_Button*, void*);
|
||||
Fl_Button *favDownButton;
|
||||
inline void cb_favDownButton_i(Fl_Button*, void*);
|
||||
static void cb_favDownButton(Fl_Button*, void*);
|
||||
Fl_Button *favCancelButton;
|
||||
inline void cb_favCancelButton_i(Fl_Button*, void*);
|
||||
static void cb_favCancelButton(Fl_Button*, void*);
|
||||
Fl_Return_Button *favOkButton;
|
||||
inline void cb_favOkButton_i(Fl_Return_Button*, void*);
|
||||
static void cb_favOkButton(Fl_Return_Button*, void*);
|
||||
public:
|
||||
~Fl_File_Chooser();
|
||||
void callback(void (*cb)(Fl_File_Chooser *, void *), void *d = 0);
|
||||
void color(Fl_Color c);
|
||||
Fl_Color color();
|
||||
int count();
|
||||
void directory(const char *d);
|
||||
char * directory();
|
||||
void filter(const char *p);
|
||||
const char * filter();
|
||||
int filter_value();
|
||||
void filter_value(int f);
|
||||
void hide();
|
||||
void iconsize(uchar s);
|
||||
uchar iconsize();
|
||||
void label(const char *l);
|
||||
const char * label();
|
||||
void ok_label(const char *l);
|
||||
const char * ok_label();
|
||||
void preview(int e);
|
||||
int preview() const { return previewButton->value(); };
|
||||
private:
|
||||
void showHidden(int e);
|
||||
void remove_hidden_files();
|
||||
public:
|
||||
void rescan();
|
||||
void rescan_keep_filename();
|
||||
void show();
|
||||
int shown();
|
||||
void textcolor(Fl_Color c);
|
||||
Fl_Color textcolor();
|
||||
void textfont(Fl_Font f);
|
||||
Fl_Font textfont();
|
||||
void textsize(Fl_Fontsize s);
|
||||
Fl_Fontsize textsize();
|
||||
void type(int t);
|
||||
int type();
|
||||
void * user_data() const;
|
||||
void user_data(void *d);
|
||||
const char *value(int f = 1);
|
||||
void value(const char *filename);
|
||||
int visible();
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *add_favorites_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *all_files_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *custom_filter_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *existing_file_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *favorites_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *filename_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *filesystems_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *manage_favorites_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *new_directory_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *new_directory_tooltip;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *preview_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *save_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *show_label;
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *hidden_label;
|
||||
/**
|
||||
the sort function that is used when loading
|
||||
the contents of a directory.
|
||||
*/
|
||||
static Fl_File_Sort_F *sort;
|
||||
private:
|
||||
Fl_Widget* ext_group;
|
||||
public:
|
||||
Fl_Widget* add_extra(Fl_Widget* gr);
|
||||
};
|
||||
FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0);
|
||||
FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname,int relative=0);
|
||||
FL_EXPORT void fl_file_chooser_callback(void (*cb)(const char*));
|
||||
FL_EXPORT void fl_file_chooser_ok_label(const char*l);
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,159 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Fl_File_Icon definitions.
|
||||
//
|
||||
// Copyright 1999-2010 by Michael Sweet.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_File_Icon widget . */
|
||||
|
||||
//
|
||||
// Include necessary header files...
|
||||
//
|
||||
|
||||
#ifndef _Fl_Fl_File_Icon_H_
|
||||
# define _Fl_Fl_File_Icon_H_
|
||||
|
||||
# include "Fl.H"
|
||||
|
||||
|
||||
//
|
||||
// Special color value for the icon color.
|
||||
//
|
||||
|
||||
# define FL_ICON_COLOR (Fl_Color)0xffffffff /**< icon color [background?]*/
|
||||
|
||||
|
||||
//
|
||||
// Fl_File_Icon class...
|
||||
//
|
||||
|
||||
/**
|
||||
The Fl_File_Icon class manages icon images that can be used
|
||||
as labels in other widgets and as icons in the FileBrowser widget.
|
||||
*/
|
||||
class FL_EXPORT Fl_File_Icon { //// Icon data
|
||||
|
||||
static Fl_File_Icon *first_; // Pointer to first icon/filetype
|
||||
Fl_File_Icon *next_; // Pointer to next icon/filetype
|
||||
const char *pattern_; // Pattern string
|
||||
int type_; // Match only if directory or file?
|
||||
int num_data_; // Number of data elements
|
||||
int alloc_data_; // Number of allocated elements
|
||||
short *data_; // Icon data
|
||||
|
||||
public:
|
||||
|
||||
enum // File types
|
||||
{
|
||||
ANY, // Any kind of file
|
||||
PLAIN, // Only plain files
|
||||
FIFO, // Only named pipes
|
||||
DEVICE, // Only character and block devices
|
||||
LINK, // Only symbolic links
|
||||
DIRECTORY // Only directories
|
||||
};
|
||||
|
||||
enum // Data opcodes
|
||||
{
|
||||
END, // End of primitive/icon
|
||||
COLOR, // Followed by color value (2 shorts)
|
||||
LINE, // Start of line
|
||||
CLOSEDLINE, // Start of closed line
|
||||
POLYGON, // Start of polygon
|
||||
OUTLINEPOLYGON, // Followed by outline color (2 shorts)
|
||||
VERTEX // Followed by scaled X,Y
|
||||
};
|
||||
|
||||
Fl_File_Icon(const char *p, int t, int nd = 0, short *d = 0);
|
||||
~Fl_File_Icon();
|
||||
|
||||
short *add(short d);
|
||||
|
||||
/**
|
||||
Adds a color value to the icon array, returning a pointer to it.
|
||||
\param[in] c color value
|
||||
*/
|
||||
short *add_color(Fl_Color c)
|
||||
{ short *d = add((short)COLOR); add((short)(c >> 16)); add((short)c); return (d); }
|
||||
|
||||
/**
|
||||
Adds a vertex value to the icon array, returning a pointer to it.
|
||||
The integer version accepts coordinates from 0 to 10000.
|
||||
The origin (0.0) is in the lower-lefthand corner of the icon.
|
||||
\param[in] x, y vertex coordinates
|
||||
*/
|
||||
short *add_vertex(int x, int y)
|
||||
{ short *d = add((short)VERTEX); add((short)x); add((short)y); return (d); }
|
||||
|
||||
/**
|
||||
Adds a vertex value to the icon array, returning a pointer to it.
|
||||
The floating point version goes from 0.0 to 1.0.
|
||||
The origin (0.0) is in the lower-lefthand corner of the icon.
|
||||
\param[in] x, y vertex coordinates
|
||||
*/
|
||||
short *add_vertex(float x, float y)
|
||||
{ short *d = add((short)VERTEX); add((short)(x * 10000.0));
|
||||
add((short)(y * 10000.0)); return (d); }
|
||||
|
||||
/** Clears all icon data from the icon.*/
|
||||
void clear() { num_data_ = 0; }
|
||||
|
||||
void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1);
|
||||
|
||||
void label(Fl_Widget *w);
|
||||
|
||||
static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a);
|
||||
void load(const char *f);
|
||||
int load_fti(const char *fti);
|
||||
int load_image(const char *i);
|
||||
|
||||
/** Returns next file icon object. See Fl_File_Icon::first() */
|
||||
Fl_File_Icon *next() { return (next_); }
|
||||
|
||||
/** Returns the filename matching pattern for the icon.*/
|
||||
const char *pattern() { return (pattern_); }
|
||||
|
||||
/** Returns the number of words of data used by the icon.*/
|
||||
int size() { return (num_data_); }
|
||||
|
||||
/**
|
||||
Returns the filetype associated with the icon, which can be one of the
|
||||
following:
|
||||
|
||||
\li Fl_File_Icon::ANY, any kind of file.
|
||||
\li Fl_File_Icon::PLAIN, plain files.
|
||||
\li Fl_File_Icon::FIFO, named pipes.
|
||||
\li Fl_File_Icon::DEVICE, character and block devices.
|
||||
\li Fl_File_Icon::LINK, symbolic links.
|
||||
\li Fl_File_Icon::DIRECTORY, directories.
|
||||
*/
|
||||
int type() { return (type_); }
|
||||
|
||||
/** Returns the data array for the icon.*/
|
||||
short *value() { return (data_); }
|
||||
|
||||
static Fl_File_Icon *find(const char *filename, int filetype = ANY);
|
||||
|
||||
/** Returns a pointer to the first icon in the list.*/
|
||||
static Fl_File_Icon *first() { return (first_); }
|
||||
static void load_system_icons(void);
|
||||
};
|
||||
|
||||
#endif // !_Fl_Fl_File_Icon_H_
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,97 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// File_Input header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
// Original version Copyright 1998 by Curtis Edwards.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_File_Input widget . */
|
||||
|
||||
#ifndef Fl_File_Input_H
|
||||
# define Fl_File_Input_H
|
||||
|
||||
# include <FL/Fl_Input.H>
|
||||
|
||||
/**
|
||||
\class Fl_File_Input
|
||||
\brief This widget displays a pathname in a text input field.
|
||||
|
||||
A navigation bar located above the input field allows the user to
|
||||
navigate upward in the directory tree.
|
||||
You may want to handle FL_WHEN_CHANGED events for tracking text changes
|
||||
and also FL_WHEN_RELEASE for button release when changing to parent dir.
|
||||
FL_WHEN_RELEASE callback won't be called if the directory clicked
|
||||
is the same as the current one.
|
||||
|
||||
<P align=CENTER> \image html Fl_File_Input.png </P>
|
||||
\image latex Fl_File_Input.png "Fl_File_Input" width=6cm
|
||||
|
||||
\note As all Fl_Input derived objects, Fl_File_Input may call its callback
|
||||
when losing focus (see FL_UNFOCUS) to update its state like its cursor shape.
|
||||
One resulting side effect is that you should call clear_changed() early in your callback
|
||||
to avoid reentrant calls if you plan to show another window or dialog box in the callback.
|
||||
*/
|
||||
class FL_EXPORT Fl_File_Input : public Fl_Input {
|
||||
|
||||
Fl_Color errorcolor_;
|
||||
char ok_entry_;
|
||||
uchar down_box_;
|
||||
short buttons_[200];
|
||||
short pressed_;
|
||||
|
||||
void draw_buttons();
|
||||
int handle_button(int event);
|
||||
void update_buttons();
|
||||
|
||||
public:
|
||||
|
||||
Fl_File_Input(int X, int Y, int W, int H, const char *L=0);
|
||||
|
||||
virtual int handle(int event);
|
||||
|
||||
protected:
|
||||
virtual void draw();
|
||||
|
||||
public:
|
||||
/** Gets the box type used for the navigation bar. */
|
||||
Fl_Boxtype down_box() const { return (Fl_Boxtype)down_box_; }
|
||||
/** Sets the box type to use for the navigation bar. */
|
||||
void down_box(Fl_Boxtype b) { down_box_ = b; }
|
||||
|
||||
/**
|
||||
Gets the current error color.
|
||||
\todo Better docs for Fl_File_Input::errorcolor() - is it even used?
|
||||
*/
|
||||
Fl_Color errorcolor() const { return errorcolor_; }
|
||||
/** Sets the current error color to \p c */
|
||||
void errorcolor(Fl_Color c) { errorcolor_ = c; }
|
||||
|
||||
int value(const char *str);
|
||||
int value(const char *str, int len);
|
||||
|
||||
/**
|
||||
Returns the current value, which is a pointer to an internal buffer
|
||||
and is valid only until the next event is handled.
|
||||
*/
|
||||
const char *value() { return Fl_Input_::value(); }
|
||||
};
|
||||
|
||||
#endif // !Fl_File_Input_H
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,38 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Filled dial header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Fill_Dial widget . */
|
||||
|
||||
#ifndef Fl_Fill_Dial_H
|
||||
#define Fl_Fill_Dial_H
|
||||
|
||||
#include "Fl_Dial.H"
|
||||
|
||||
/** Draws a dial with a filled arc */
|
||||
class FL_EXPORT Fl_Fill_Dial : public Fl_Dial {
|
||||
public:
|
||||
/** Creates a filled dial, also setting its type to FL_FILL_DIAL. */
|
||||
Fl_Fill_Dial(int X,int Y,int W,int H, const char *L);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,37 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Filled slider header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Fill_Slider widget . */
|
||||
|
||||
#ifndef Fl_Fill_Slider_H
|
||||
#define Fl_Fill_Slider_H
|
||||
|
||||
#include "Fl_Slider.H"
|
||||
/** Widget that draws a filled horizontal slider, useful as a progress or value meter*/
|
||||
class FL_EXPORT Fl_Fill_Slider : public Fl_Slider {
|
||||
public:
|
||||
/** Creates the slider from its position,size and optional title. */
|
||||
Fl_Fill_Slider(int X,int Y,int W,int H,const char *L=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,47 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Floating point input header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2011 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Float_Input widget . */
|
||||
|
||||
#ifndef Fl_Float_Input_H
|
||||
#define Fl_Float_Input_H
|
||||
|
||||
#include "Fl_Input.H"
|
||||
|
||||
/**
|
||||
The Fl_Float_Input class is a subclass of Fl_Input
|
||||
that only allows the user to type floating point numbers (sign,
|
||||
digits, decimal point, more digits, 'E' or 'e', sign, digits).
|
||||
*/
|
||||
class FL_EXPORT Fl_Float_Input : public Fl_Input {
|
||||
public:
|
||||
/**
|
||||
Creates a new Fl_Float_Input widget using the given position,
|
||||
size, and label string. The default boxtype is FL_DOWN_BOX.
|
||||
|
||||
Inherited destructor destroys the widget and any value associated with it.
|
||||
*/
|
||||
Fl_Float_Input(int X,int Y,int W,int H,const char *l = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,47 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Forms bitmap header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_FormsBitmap widget . */
|
||||
|
||||
#ifndef Fl_FormsBitmap_H
|
||||
#define Fl_FormsBitmap_H
|
||||
|
||||
#include "Fl_Bitmap.H"
|
||||
|
||||
/**
|
||||
Forms compatibility Bitmap Image Widget
|
||||
*/
|
||||
class FL_EXPORT Fl_FormsBitmap : public Fl_Widget {
|
||||
Fl_Bitmap *b;
|
||||
protected:
|
||||
void draw();
|
||||
public:
|
||||
Fl_FormsBitmap(Fl_Boxtype, int, int, int, int, const char * = 0);
|
||||
void set(int W, int H, const uchar *bits);
|
||||
/** Sets a new bitmap. */
|
||||
void bitmap(Fl_Bitmap *B) {b = B;}
|
||||
/** Gets a the current associated Fl_Bitmap objects. */
|
||||
Fl_Bitmap *bitmap() const {return b;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,54 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Forms pixmap header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_FormsPixmap widget . */
|
||||
|
||||
#ifndef Fl_FormsPixmap_H
|
||||
#define Fl_FormsPixmap_H
|
||||
|
||||
#include "Fl_Pixmap.H"
|
||||
|
||||
/**
|
||||
\class Fl_FormsPixmap
|
||||
\brief Forms pixmap drawing routines
|
||||
*/
|
||||
class FL_EXPORT Fl_FormsPixmap : public Fl_Widget {
|
||||
Fl_Pixmap *b;
|
||||
protected:
|
||||
void draw();
|
||||
public:
|
||||
Fl_FormsPixmap(Fl_Boxtype t, int X, int Y, int W, int H, const char *L= 0);
|
||||
|
||||
void set(/*const*/char * const * bits);
|
||||
|
||||
/**
|
||||
Set the internal pixmap pointer to an existing pixmap.
|
||||
\param[in] B existing pixmap
|
||||
*/
|
||||
void Pixmap(Fl_Pixmap *B) {b = B;}
|
||||
|
||||
/** Get the internal pixmap pointer. */
|
||||
Fl_Pixmap *Pixmap() const {return b;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,80 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Forms free header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Free widget . */
|
||||
|
||||
#ifndef Fl_Free_H
|
||||
#define Fl_Free_H
|
||||
|
||||
#ifndef Fl_Widget_H
|
||||
#include "Fl_Widget.H"
|
||||
#endif
|
||||
|
||||
#define FL_NORMAL_FREE 1 /**< normal event handling */
|
||||
#define FL_SLEEPING_FREE 2 /**< deactivate event handling */
|
||||
#define FL_INPUT_FREE 3 /**< accepts FL_FOCUS events */
|
||||
#define FL_CONTINUOUS_FREE 4 /**< repeated timeout handling */
|
||||
#define FL_ALL_FREE 5 /**< FL_INPUT_FREE and FL_CONTINOUS_FREE */
|
||||
|
||||
/** appropriate signature for handle function */
|
||||
typedef int (*FL_HANDLEPTR)(Fl_Widget *, int , float, float, char);
|
||||
|
||||
/**
|
||||
Emulation of the Forms "free" widget.
|
||||
|
||||
This emulation allows the free demo to run, and appears to be useful for
|
||||
porting programs written in Forms which use the free widget or make
|
||||
subclasses of the Forms widgets.
|
||||
|
||||
There are five types of free, which determine when the handle function
|
||||
is called:
|
||||
|
||||
\li \c FL_NORMAL_FREE normal event handling.
|
||||
\li \c FL_SLEEPING_FREE deactivates event handling (widget is inactive).
|
||||
\li \c FL_INPUT_FREE accepts FL_FOCUS events.
|
||||
\li \c FL_CONTINUOUS_FREE sets a timeout callback 100 times a second and
|
||||
provides an FL_STEP event. This has obvious
|
||||
detrimental effects on machine performance.
|
||||
\li \c FL_ALL_FREE same as FL_INPUT_FREE and FL_CONTINUOUS_FREE.
|
||||
|
||||
*/
|
||||
class FL_EXPORT Fl_Free : public Fl_Widget {
|
||||
FL_HANDLEPTR hfunc;
|
||||
static void step(void *);
|
||||
protected:
|
||||
void draw();
|
||||
public:
|
||||
int handle(int e);
|
||||
Fl_Free(uchar t,int X,int Y,int W,int H,const char *L,FL_HANDLEPTR hdl);
|
||||
~Fl_Free();
|
||||
};
|
||||
|
||||
// old event names for compatibility:
|
||||
#define FL_MOUSE FL_DRAG /**< for backward compatibility */
|
||||
#define FL_DRAW 100 /**< for backward compatibility [UNUSED]*/
|
||||
#define FL_STEP 101 /**< for backward compatibility */
|
||||
#define FL_FREEMEM 102 /**< for backward compatibility [UNUSED]*/
|
||||
#define FL_FREEZE 103 /**< for backward compatibility [UNUSED]*/
|
||||
#define FL_THAW 104 /**< for backward compatibility [UNUSED]*/
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,42 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// GIF image header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_GIF_Image widget . */
|
||||
|
||||
#ifndef Fl_GIF_Image_H
|
||||
#define Fl_GIF_Image_H
|
||||
# include "Fl_Pixmap.H"
|
||||
|
||||
/**
|
||||
The Fl_GIF_Image class supports loading, caching,
|
||||
and drawing of Compuserve GIF<SUP>SM</SUP> images. The class
|
||||
loads the first image and supports transparency.
|
||||
*/
|
||||
class FL_EXPORT Fl_GIF_Image : public Fl_Pixmap {
|
||||
|
||||
public:
|
||||
|
||||
Fl_GIF_Image(const char* filename);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,284 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// OpenGL header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2015 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Gl_Window widget . */
|
||||
|
||||
#ifndef Fl_Gl_Window_H
|
||||
#define Fl_Gl_Window_H
|
||||
|
||||
#include "Fl_Window.H"
|
||||
|
||||
#ifndef GLContext
|
||||
/**
|
||||
Opaque pointer type to hide system specific implementation.
|
||||
*/
|
||||
typedef void* GLContext; // actually a GLXContext or HGLDC
|
||||
#endif
|
||||
|
||||
class Fl_Gl_Choice; // structure to hold result of glXChooseVisual
|
||||
|
||||
/**
|
||||
The Fl_Gl_Window widget sets things up so OpenGL works.
|
||||
|
||||
It also keeps an OpenGL "context" for that window, so that changes to the
|
||||
lighting and projection may be reused between redraws. Fl_Gl_Window
|
||||
also flushes the OpenGL streams and swaps buffers after draw() returns.
|
||||
|
||||
OpenGL hardware typically provides some overlay bit planes, which
|
||||
are very useful for drawing UI controls atop your 3D graphics. If the
|
||||
overlay hardware is not provided, FLTK tries to simulate the overlay.
|
||||
This works pretty well if your graphics are double buffered, but not
|
||||
very well for single-buffered.
|
||||
|
||||
Please note that the FLTK drawing and clipping functions
|
||||
will not work inside an Fl_Gl_Window. All drawing
|
||||
should be done using OpenGL calls exclusively.
|
||||
Even though Fl_Gl_Window is derived from Fl_Group,
|
||||
it is not useful to add other FLTK Widgets as children,
|
||||
unless those widgets are modified to draw using OpenGL calls.
|
||||
*/
|
||||
class FL_EXPORT Fl_Gl_Window : public Fl_Window {
|
||||
|
||||
int mode_;
|
||||
const int *alist;
|
||||
Fl_Gl_Choice *g;
|
||||
GLContext context_;
|
||||
char valid_f_;
|
||||
char damage1_; // damage() of back buffer
|
||||
virtual void draw_overlay();
|
||||
void init();
|
||||
|
||||
void *overlay;
|
||||
void make_overlay();
|
||||
friend class _Fl_Gl_Overlay;
|
||||
|
||||
static int can_do(int, const int *);
|
||||
int mode(int, const int *);
|
||||
static int gl_plugin_linkage();
|
||||
|
||||
public:
|
||||
|
||||
void show();
|
||||
void show(int a, char **b) {Fl_Window::show(a,b);}
|
||||
void flush();
|
||||
void hide();
|
||||
void resize(int,int,int,int);
|
||||
int handle(int);
|
||||
|
||||
/**
|
||||
Is turned off when FLTK creates a new context for this window or
|
||||
when the window resizes, and is turned on \e after draw() is called.
|
||||
You can use this inside your draw() method to avoid unnecessarily
|
||||
initializing the OpenGL context. Just do this:
|
||||
\code
|
||||
void mywindow::draw() {
|
||||
if (!valid()) {
|
||||
glViewport(0,0,pixel_w(),pixel_h());
|
||||
glFrustum(...);
|
||||
...other initialization...
|
||||
}
|
||||
if (!context_valid()) {
|
||||
...load textures, etc. ...
|
||||
}
|
||||
... draw your geometry here ...
|
||||
}
|
||||
\endcode
|
||||
|
||||
You can turn valid() on by calling valid(1). You
|
||||
should only do this after fixing the transformation inside a draw()
|
||||
or after make_current(). This is done automatically after
|
||||
draw() returns.
|
||||
*/
|
||||
char valid() const {return valid_f_ & 1;}
|
||||
/**
|
||||
See char Fl_Gl_Window::valid() const
|
||||
*/
|
||||
void valid(char v) {if (v) valid_f_ |= 1; else valid_f_ &= 0xfe;}
|
||||
void invalidate();
|
||||
|
||||
/**
|
||||
Will only be set if the
|
||||
OpenGL context is created or recreated. It differs from
|
||||
Fl_Gl_Window::valid() which is also set whenever the context
|
||||
changes size.
|
||||
*/
|
||||
char context_valid() const {return valid_f_ & 2;}
|
||||
/**
|
||||
See char Fl_Gl_Window::context_valid() const
|
||||
*/
|
||||
void context_valid(char v) {if (v) valid_f_ |= 2; else valid_f_ &= 0xfd;}
|
||||
|
||||
/** Returns non-zero if the hardware supports the given OpenGL mode. */
|
||||
static int can_do(int m) {return can_do(m,0);}
|
||||
/** Returns non-zero if the hardware supports the given OpenGL mode.
|
||||
\see Fl_Gl_Window::mode(const int *a) */
|
||||
static int can_do(const int *m) {return can_do(0, m);}
|
||||
/** Returns non-zero if the hardware supports the current OpenGL mode. */
|
||||
int can_do() {return can_do(mode_,alist);}
|
||||
/** Returns the current OpenGL capabilites of the window.
|
||||
Don't use this if capabilities were set through Fl_Gl_Window::mode(const int *a).
|
||||
*/
|
||||
Fl_Mode mode() const {return (Fl_Mode)mode_;}
|
||||
/**
|
||||
Set or change the OpenGL capabilites of the window. The value can be
|
||||
any of the following OR'd together:
|
||||
|
||||
- \c FL_RGB - RGB color (not indexed)
|
||||
- \c FL_RGB8 - RGB color with at least 8 bits of each color
|
||||
- \c FL_INDEX - Indexed mode
|
||||
- \c FL_SINGLE - not double buffered
|
||||
- \c FL_DOUBLE - double buffered
|
||||
- \c FL_ACCUM - accumulation buffer
|
||||
- \c FL_ALPHA - alpha channel in color
|
||||
- \c FL_DEPTH - depth buffer
|
||||
- \c FL_STENCIL - stencil buffer
|
||||
- \c FL_MULTISAMPLE - multisample antialiasing
|
||||
- \c FL_OPENGL3 - use OpenGL version 3.0 or more.
|
||||
|
||||
FL_RGB and FL_SINGLE have a value of zero, so they
|
||||
are "on" unless you give FL_INDEX or FL_DOUBLE.
|
||||
|
||||
If the desired combination cannot be done, FLTK will try turning off
|
||||
FL_MULTISAMPLE. If this also fails the show() will call
|
||||
Fl::error() and not show the window.
|
||||
|
||||
You can change the mode while the window is displayed. This is most
|
||||
useful for turning double-buffering on and off. Under X this will
|
||||
cause the old X window to be destroyed and a new one to be created. If
|
||||
this is a top-level window this will unfortunately also cause the
|
||||
window to blink, raise to the top, and be de-iconized, and the xid()
|
||||
will change, possibly breaking other code. It is best to make the GL
|
||||
window a child of another window if you wish to do this!
|
||||
|
||||
mode() must not be called within draw() since it
|
||||
changes the current context.
|
||||
|
||||
The FL_OPENGL3 flag is required to access OpenGL version 3 or more
|
||||
under the X11 and MacOS platforms; it's optional under Windows.
|
||||
See more details in \ref opengl3.
|
||||
|
||||
\version the <tt>FL_OPENGL3</tt> flag appeared in version 1.3.4
|
||||
*/
|
||||
int mode(int a) {return mode(a,0);}
|
||||
/** Set the OpenGL capabilites of the window using platform-specific data.
|
||||
\param a zero-ending array of platform-specific attributes and attribute values
|
||||
<p><b>Unix/Linux platform</b>: attributes are GLX attributes adequate for the 3rd argument of
|
||||
the <tt>glXChooseVisual()</tt> function (e.g., <tt>GLX_DOUBLEBUFFER</tt>, defined by including <GL/glx.h>).
|
||||
\note What attributes are adequate here is subject to change.
|
||||
The preferred, stable public API is Fl_Gl_Window::mode(int a).
|
||||
<p><b>MSWindows platform</b>: this member function is of no use.
|
||||
<p><b>Mac OS X platform</b>: attributes belong to the <tt>CGLPixelFormatAttribute</tt> enumeration
|
||||
(defined by including <tt><OpenGL/OpenGL.h></tt>, e.g., <tt>kCGLPFADoubleBuffer</tt>)
|
||||
and may be followed by adequate attribute values.
|
||||
*/
|
||||
int mode(const int *a) {return mode(0, a);}
|
||||
/** Returns a pointer to the GLContext that this window is using.
|
||||
\see void context(void* v, int destroy_flag) */
|
||||
void* context() const {return context_;}
|
||||
void context(void*, int destroy_flag = 0);
|
||||
void make_current();
|
||||
void swap_buffers();
|
||||
void ortho();
|
||||
|
||||
/**
|
||||
Returns true if the hardware overlay is possible. If this is false,
|
||||
FLTK will try to simulate the overlay, with significant loss of update
|
||||
speed. Calling this will cause FLTK to open the display.
|
||||
*/
|
||||
int can_do_overlay();
|
||||
/**
|
||||
This method causes draw_overlay() to be called at a later time.
|
||||
Initially the overlay is clear. If you want the window to display
|
||||
something in the overlay when it first appears, you must call this
|
||||
immediately after you show() your window.
|
||||
*/
|
||||
void redraw_overlay();
|
||||
void hide_overlay();
|
||||
/**
|
||||
The make_overlay_current() method selects the OpenGL context
|
||||
for the widget's overlay. It is called automatically prior to the
|
||||
draw_overlay() method being called and can also be used to
|
||||
implement feedback and/or selection within the handle()
|
||||
method.
|
||||
*/
|
||||
void make_overlay_current();
|
||||
|
||||
// Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
|
||||
virtual Fl_Gl_Window* as_gl_window() {return this;}
|
||||
|
||||
/** The number of pixels per FLTK unit of length for the window.
|
||||
Returns 1, except for a window mapped to
|
||||
an Apple 'retina' display, and if Fl::use_high_res_GL(bool) is set to true,
|
||||
when it returns 2. This method dynamically adjusts its value when the window
|
||||
is moved to/from a retina display. This method is useful, e.g., to convert,
|
||||
in a window's handle() method, the FLTK units returned by Fl::event_x() and
|
||||
Fl::event_y() to the pixel units used by the OpenGL source code.
|
||||
\version 1.3.4
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
float pixels_per_unit();
|
||||
#else
|
||||
float pixels_per_unit() { return 1; }
|
||||
#endif
|
||||
/** Gives the window width in OpenGL pixels.
|
||||
Generally identical with the result of the w() function, but for a window mapped to
|
||||
an Apple 'retina' display, and if Fl::use_high_res_GL(bool) is set to true,
|
||||
pixel_w() returns 2 * w(). This method detects when the window has been moved
|
||||
between low and high resolution displays and automatically adjusts the returned value.
|
||||
\version 1.3.4
|
||||
*/
|
||||
int pixel_w() { return int(pixels_per_unit() * w() + 0.5); }
|
||||
/** Gives the window height in OpenGL pixels.
|
||||
Generally identical with the result of the h() function, but for a window mapped to
|
||||
an Apple 'retina' display, and if Fl::use_high_res_GL(bool) is set to true,
|
||||
pixel_h() returns 2 * h(). This method detects when the window has been moved
|
||||
between low and high resolution displays and automatically adjusts the returned value.
|
||||
\version 1.3.4
|
||||
*/
|
||||
int pixel_h() { return int(pixels_per_unit() * h() + 0.5); }
|
||||
|
||||
~Fl_Gl_Window();
|
||||
/**
|
||||
Creates a new Fl_Gl_Window widget using the given size, and label string.
|
||||
The default boxtype is FL_NO_BOX. The default mode is FL_RGB|FL_DOUBLE|FL_DEPTH.
|
||||
*/
|
||||
Fl_Gl_Window(int W, int H, const char *l=0) : Fl_Window(W,H,l) {init();}
|
||||
/**
|
||||
Creates a new Fl_Gl_Window widget using the given position,
|
||||
size, and label string. The default boxtype is FL_NO_BOX. The
|
||||
default mode is FL_RGB|FL_DOUBLE|FL_DEPTH.
|
||||
*/
|
||||
|
||||
Fl_Gl_Window(int X, int Y, int W, int H, const char *l=0)
|
||||
: Fl_Window(X,Y,W,H,l) {init();}
|
||||
|
||||
protected:
|
||||
/**
|
||||
Draws the Fl_Gl_Window.
|
||||
|
||||
You \e \b must override the draw() method.
|
||||
*/
|
||||
virtual void draw();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,228 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Group header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Group, Fl_End classes . */
|
||||
|
||||
#ifndef Fl_Group_H
|
||||
#define Fl_Group_H
|
||||
|
||||
#ifndef Fl_Widget_H
|
||||
#include "Fl_Widget.H"
|
||||
#endif
|
||||
|
||||
/**
|
||||
The Fl_Group class is the FLTK container widget. It maintains
|
||||
an array of child widgets. These children can themselves be any widget
|
||||
including Fl_Group. The most important subclass of Fl_Group
|
||||
is Fl_Window, however groups can also be used to control radio buttons
|
||||
or to enforce resize behavior.
|
||||
|
||||
The tab and arrow keys are used to move the focus between widgets of
|
||||
this group, and to other groups. The only modifier grabbed is shift
|
||||
(for shift-tab), so that ctrl-tab, alt-up, and such are free
|
||||
for the app to use as shortcuts.
|
||||
*/
|
||||
class FL_EXPORT Fl_Group : public Fl_Widget {
|
||||
|
||||
Fl_Widget** array_;
|
||||
Fl_Widget* savedfocus_;
|
||||
Fl_Widget* resizable_;
|
||||
int children_;
|
||||
int *sizes_; // remembered initial sizes of children
|
||||
|
||||
int navigation(int);
|
||||
static Fl_Group *current_;
|
||||
|
||||
// unimplemented copy ctor and assignment operator
|
||||
Fl_Group(const Fl_Group&);
|
||||
Fl_Group& operator=(const Fl_Group&);
|
||||
|
||||
protected:
|
||||
void draw();
|
||||
void draw_child(Fl_Widget& widget) const;
|
||||
void draw_children();
|
||||
void draw_outside_label(const Fl_Widget& widget) const ;
|
||||
void update_child(Fl_Widget& widget) const;
|
||||
int *sizes();
|
||||
|
||||
public:
|
||||
|
||||
int handle(int);
|
||||
void begin();
|
||||
void end();
|
||||
static Fl_Group *current();
|
||||
static void current(Fl_Group *g);
|
||||
|
||||
/**
|
||||
Returns how many child widgets the group has.
|
||||
*/
|
||||
int children() const {return children_;}
|
||||
/**
|
||||
Returns array()[n]. <i>No range checking is done!</i>
|
||||
*/
|
||||
Fl_Widget* child(int n) const {return array()[n];}
|
||||
int find(const Fl_Widget*) const;
|
||||
/**
|
||||
See int Fl_Group::find(const Fl_Widget *w) const
|
||||
*/
|
||||
int find(const Fl_Widget& o) const {return find(&o);}
|
||||
Fl_Widget* const* array() const;
|
||||
|
||||
void resize(int,int,int,int);
|
||||
/**
|
||||
Creates a new Fl_Group widget using the given position, size,
|
||||
and label string. The default boxtype is FL_NO_BOX.
|
||||
*/
|
||||
Fl_Group(int,int,int,int, const char * = 0);
|
||||
virtual ~Fl_Group();
|
||||
void add(Fl_Widget&);
|
||||
/**
|
||||
See void Fl_Group::add(Fl_Widget &w)
|
||||
*/
|
||||
void add(Fl_Widget* o) {add(*o);}
|
||||
void insert(Fl_Widget&, int i);
|
||||
/**
|
||||
This does insert(w, find(before)). This will append the
|
||||
widget if \p before is not in the group.
|
||||
*/
|
||||
void insert(Fl_Widget& o, Fl_Widget* before) {insert(o,find(before));}
|
||||
void remove(int index);
|
||||
void remove(Fl_Widget&);
|
||||
/**
|
||||
Removes the widget \p o from the group.
|
||||
\sa void remove(Fl_Widget&)
|
||||
*/
|
||||
void remove(Fl_Widget* o) {remove(*o);}
|
||||
void clear();
|
||||
|
||||
/**
|
||||
See void Fl_Group::resizable(Fl_Widget *box)
|
||||
*/
|
||||
void resizable(Fl_Widget& o) {resizable_ = &o;}
|
||||
/**
|
||||
The resizable widget defines the resizing box for the group. When the
|
||||
group is resized it calculates a new size and position for all of its
|
||||
children. Widgets that are horizontally or vertically inside the
|
||||
dimensions of the box are scaled to the new size. Widgets outside the
|
||||
box are moved.
|
||||
|
||||
In these examples the gray area is the resizable:
|
||||
|
||||
\image html resizebox1.png
|
||||
|
||||
<br>
|
||||
|
||||
\image html resizebox2.png
|
||||
|
||||
\image latex resizebox1.png "before resize" width=4cm
|
||||
|
||||
\image latex resizebox2.png "after resize" width=4.85cm
|
||||
|
||||
The resizable may be set to the group itself, in which case all the
|
||||
contents are resized. This is the default value for Fl_Group,
|
||||
although NULL is the default for Fl_Window and Fl_Pack.
|
||||
|
||||
If the resizable is NULL then all widgets remain a fixed size
|
||||
and distance from the top-left corner.
|
||||
|
||||
It is possible to achieve any type of resize behavior by using an
|
||||
invisible Fl_Box as the resizable and/or by using a hierarchy
|
||||
of child Fl_Group's.
|
||||
*/
|
||||
void resizable(Fl_Widget* o) {resizable_ = o;}
|
||||
/**
|
||||
See void Fl_Group::resizable(Fl_Widget *box)
|
||||
*/
|
||||
Fl_Widget* resizable() const {return resizable_;}
|
||||
/**
|
||||
Adds a widget to the group and makes it the resizable widget.
|
||||
*/
|
||||
void add_resizable(Fl_Widget& o) {resizable_ = &o; add(o);}
|
||||
void init_sizes();
|
||||
|
||||
/**
|
||||
Controls whether the group widget clips the drawing of
|
||||
child widgets to its bounding box.
|
||||
|
||||
Set \p c to 1 if you want to clip the child widgets to the
|
||||
bounding box.
|
||||
|
||||
The default is to not clip (0) the drawing of child widgets.
|
||||
*/
|
||||
void clip_children(int c) { if (c) set_flag(CLIP_CHILDREN); else clear_flag(CLIP_CHILDREN); }
|
||||
/**
|
||||
Returns the current clipping mode.
|
||||
|
||||
\return true, if clipping is enabled, false otherwise.
|
||||
|
||||
\see void Fl_Group::clip_children(int c)
|
||||
*/
|
||||
unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
|
||||
|
||||
// Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
|
||||
virtual Fl_Group* as_group() { return this; }
|
||||
|
||||
// back compatibility functions:
|
||||
|
||||
/**
|
||||
\deprecated This is for backwards compatibility only. You should use
|
||||
\e W->%take_focus() instead.
|
||||
\sa Fl_Widget::take_focus();
|
||||
*/
|
||||
void focus(Fl_Widget* W) {W->take_focus();}
|
||||
|
||||
/** This is for forms compatibility only */
|
||||
Fl_Widget* & _ddfdesign_kludge() {return resizable_;}
|
||||
|
||||
/** This is for forms compatibility only */
|
||||
void forms_end();
|
||||
};
|
||||
|
||||
// dummy class used to end child groups in constructors for complex
|
||||
// subclasses of Fl_Group:
|
||||
/**
|
||||
This is a dummy class that allows you to end a Fl_Group in a constructor list of a
|
||||
class:
|
||||
\code
|
||||
class MyClass {
|
||||
Fl_Group group;
|
||||
Fl_Button button_in_group;
|
||||
Fl_End end;
|
||||
Fl_Button button_outside_group;
|
||||
MyClass();
|
||||
};
|
||||
MyClass::MyClass() :
|
||||
group(10,10,100,100),
|
||||
button_in_group(20,20,60,30),
|
||||
end(),
|
||||
button_outside_group(10,120,60,30)
|
||||
{}
|
||||
\endcode
|
||||
*/
|
||||
class FL_EXPORT Fl_End {
|
||||
public:
|
||||
/** All it does is calling Fl_Group::current()->end() */
|
||||
Fl_End() {Fl_Group::current()->end();}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,90 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Fl_Help_Dialog dialog for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2015 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
// ========================================================================
|
||||
// DO NOT EDIT FL/Fl_Help_Dialog.H and src/Fl_Help_Dialog.cxx !!!
|
||||
// ========================================================================
|
||||
// Please use fluid to change src/Fl_Help_Dialog.fl interactively
|
||||
// and then use fluid to "write code" or edit and use fluid -c .
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
// generated by Fast Light User Interface Designer (fluid) version 1.0305
|
||||
|
||||
#ifndef Fl_Help_Dialog_H
|
||||
#define Fl_Help_Dialog_H
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Input.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/Fl_Help_View.H>
|
||||
|
||||
class FL_EXPORT Fl_Help_Dialog {
|
||||
int index_;
|
||||
int max_;
|
||||
int line_[100]; // FIXME: we must remove those static numbers
|
||||
char file_[100][FL_PATH_MAX]; // FIXME: we must remove those static numbers
|
||||
int find_pos_;
|
||||
public:
|
||||
Fl_Help_Dialog();
|
||||
private:
|
||||
Fl_Double_Window *window_;
|
||||
Fl_Button *back_;
|
||||
inline void cb_back__i(Fl_Button*, void*);
|
||||
static void cb_back_(Fl_Button*, void*);
|
||||
Fl_Button *forward_;
|
||||
inline void cb_forward__i(Fl_Button*, void*);
|
||||
static void cb_forward_(Fl_Button*, void*);
|
||||
Fl_Button *smaller_;
|
||||
inline void cb_smaller__i(Fl_Button*, void*);
|
||||
static void cb_smaller_(Fl_Button*, void*);
|
||||
Fl_Button *larger_;
|
||||
inline void cb_larger__i(Fl_Button*, void*);
|
||||
static void cb_larger_(Fl_Button*, void*);
|
||||
Fl_Input *find_;
|
||||
inline void cb_find__i(Fl_Input*, void*);
|
||||
static void cb_find_(Fl_Input*, void*);
|
||||
Fl_Help_View *view_;
|
||||
inline void cb_view__i(Fl_Help_View*, void*);
|
||||
static void cb_view_(Fl_Help_View*, void*);
|
||||
public:
|
||||
~Fl_Help_Dialog();
|
||||
int h();
|
||||
void hide();
|
||||
void load(const char *f);
|
||||
void position(int xx, int yy);
|
||||
void resize(int xx, int yy, int ww, int hh);
|
||||
void show();
|
||||
void show(int argc, char **argv);
|
||||
void textsize(Fl_Fontsize s);
|
||||
Fl_Fontsize textsize();
|
||||
void topline(const char *n);
|
||||
void topline(int n);
|
||||
void value(const char *f);
|
||||
const char * value() const;
|
||||
int visible();
|
||||
int w();
|
||||
int x();
|
||||
int y();
|
||||
};
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,399 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Help Viewer widget definitions.
|
||||
//
|
||||
// Copyright 1997-2010 by Easy Software Products.
|
||||
// Image support by Matthias Melcher, Copyright 2000-2009.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Help_View widget . */
|
||||
|
||||
#ifndef Fl_Help_View_H
|
||||
# define Fl_Help_View_H
|
||||
|
||||
//
|
||||
// Include necessary header files...
|
||||
//
|
||||
|
||||
# include <stdio.h>
|
||||
# include "Fl.H"
|
||||
# include "Fl_Group.H"
|
||||
# include "Fl_Scrollbar.H"
|
||||
# include "fl_draw.H"
|
||||
# include "Fl_Shared_Image.H"
|
||||
# include "filename.H"
|
||||
|
||||
|
||||
//
|
||||
// Fl_Help_Func type - link callback function for files...
|
||||
//
|
||||
|
||||
|
||||
typedef const char *(Fl_Help_Func)(Fl_Widget *, const char *);
|
||||
|
||||
|
||||
//
|
||||
// Fl_Help_Block structure...
|
||||
//
|
||||
|
||||
struct Fl_Help_Block {
|
||||
const char *start, // Start of text
|
||||
*end; // End of text
|
||||
uchar border; // Draw border?
|
||||
Fl_Color bgcolor; // Background color
|
||||
int x, // Indentation/starting X coordinate
|
||||
y, // Starting Y coordinate
|
||||
w, // Width
|
||||
h; // Height
|
||||
int line[32]; // Left starting position for each line
|
||||
};
|
||||
|
||||
//
|
||||
// Fl_Help_Link structure...
|
||||
//
|
||||
/** Definition of a link for the html viewer. */
|
||||
struct Fl_Help_Link {
|
||||
char filename[192], ///< Reference filename
|
||||
name[32]; ///< Link target (blank if none)
|
||||
int x, ///< X offset of link text
|
||||
y, ///< Y offset of link text
|
||||
w, ///< Width of link text
|
||||
h; ///< Height of link text
|
||||
};
|
||||
|
||||
/*
|
||||
* Fl_Help_View font stack opaque implementation
|
||||
*/
|
||||
|
||||
/** Fl_Help_View font stack element definition. */
|
||||
struct FL_EXPORT Fl_Help_Font_Style {
|
||||
Fl_Font f; ///< Font
|
||||
Fl_Fontsize s; ///< Font Size
|
||||
Fl_Color c; ///< Font Color
|
||||
void get(Fl_Font &afont, Fl_Fontsize &asize, Fl_Color &acolor) {afont=f; asize=s; acolor=c;} ///< Gets current font attributes
|
||||
void set(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor) {f=afont; s=asize; c=acolor;} ///< Sets current font attributes
|
||||
Fl_Help_Font_Style(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor) {set(afont, asize, acolor);}
|
||||
Fl_Help_Font_Style(){} // For in table use
|
||||
};
|
||||
|
||||
/** Fl_Help_View font stack definition. */
|
||||
const size_t MAX_FL_HELP_FS_ELTS = 100;
|
||||
|
||||
struct FL_EXPORT Fl_Help_Font_Stack {
|
||||
/** font stack construction, initialize attributes. */
|
||||
Fl_Help_Font_Stack() {
|
||||
nfonts_ = 0;
|
||||
}
|
||||
|
||||
void init(Fl_Font f, Fl_Fontsize s, Fl_Color c) {
|
||||
nfonts_ = 0;
|
||||
elts_[nfonts_].set(f, s, c);
|
||||
fl_font(f, s);
|
||||
fl_color(c);
|
||||
}
|
||||
/** Gets the top (current) element on the stack. */
|
||||
void top(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) { elts_[nfonts_].get(f, s, c); }
|
||||
/** Pushes the font style triplet on the stack, also calls fl_font() & fl_color() adequately */
|
||||
void push(Fl_Font f, Fl_Fontsize s, Fl_Color c) {
|
||||
if (nfonts_ < MAX_FL_HELP_FS_ELTS-1) nfonts_ ++;
|
||||
elts_[nfonts_].set(f, s, c);
|
||||
fl_font(f, s); fl_color(c);
|
||||
}
|
||||
/** Pops from the stack the font style triplet and calls fl_font() & fl_color() adequately */
|
||||
void pop(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) {
|
||||
if (nfonts_ > 0) nfonts_ --;
|
||||
top(f, s, c);
|
||||
fl_font(f, s); fl_color(c);
|
||||
}
|
||||
/** Gets the current count of font style elements in the stack. */
|
||||
size_t count() const {return nfonts_;} // Gets the current number of fonts in the stack
|
||||
|
||||
protected:
|
||||
size_t nfonts_; ///< current number of fonts in stack
|
||||
Fl_Help_Font_Style elts_[100]; ///< font elements
|
||||
};
|
||||
|
||||
/** Fl_Help_Target structure */
|
||||
|
||||
struct Fl_Help_Target {
|
||||
char name[32]; ///< Target name
|
||||
int y; ///< Y offset of target
|
||||
};
|
||||
|
||||
/**
|
||||
The Fl_Help_View widget displays HTML text. Most HTML 2.0
|
||||
elements are supported, as well as a primitive implementation of tables.
|
||||
GIF, JPEG, and PNG images are displayed inline.
|
||||
|
||||
Supported HTML tags:
|
||||
- A: HREF/NAME
|
||||
- B
|
||||
- BODY: BGCOLOR/TEXT/LINK
|
||||
- BR
|
||||
- CENTER
|
||||
- CODE
|
||||
- DD
|
||||
- DL
|
||||
- DT
|
||||
- EM
|
||||
- FONT: COLOR/SIZE/FACE=(helvetica/arial/sans/times/serif/symbol/courier)
|
||||
- H1/H2/H3/H4/H5/H6
|
||||
- HEAD
|
||||
- HR
|
||||
- I
|
||||
- IMG: SRC/WIDTH/HEIGHT/ALT
|
||||
- KBD
|
||||
- LI
|
||||
- OL
|
||||
- P
|
||||
- PRE
|
||||
- STRONG
|
||||
- TABLE: TH/TD/TR/BORDER/BGCOLOR/COLSPAN/ALIGN=CENTER|RIGHT|LEFT
|
||||
- TITLE
|
||||
- TT
|
||||
- U
|
||||
- UL
|
||||
- VAR
|
||||
|
||||
Supported color names:
|
||||
- black,red,green,yellow,blue,magenta,fuchsia,cyan,aqua,white,gray,grey,lime,maroon,navy,olive,purple,silver,teal.
|
||||
|
||||
Supported urls:
|
||||
- Internal: file:
|
||||
- External: http: ftp: https: ipp: mailto: news:
|
||||
|
||||
Quoted char names:
|
||||
- Aacute aacute Acirc acirc acute AElig aelig Agrave agrave amp Aring aring Atilde atilde Auml auml
|
||||
- brvbar bull
|
||||
- Ccedil ccedil cedil cent copy curren
|
||||
- deg divide
|
||||
- Eacute eacute Ecirc ecirc Egrave egrave ETH eth Euml euml euro
|
||||
- frac12 frac14 frac34
|
||||
- gt
|
||||
- Iacute iacute Icirc icirc iexcl Igrave igrave iquest Iuml iuml
|
||||
- laquo lt
|
||||
- macr micro middot
|
||||
- nbsp not Ntilde ntilde
|
||||
- Oacute oacute Ocirc ocirc Ograve ograve ordf ordm Oslash oslash Otilde otilde Ouml ouml
|
||||
- para permil plusmn pound
|
||||
- quot
|
||||
- raquo reg
|
||||
- sect shy sup1 sup2 sup3 szlig
|
||||
- THORN thorn times trade
|
||||
- Uacute uacute Ucirc ucirc Ugrave ugrave uml Uuml uuml
|
||||
- Yacute yacute
|
||||
- yen Yuml yuml
|
||||
|
||||
*/
|
||||
class FL_EXPORT Fl_Help_View : public Fl_Group { // Help viewer widget
|
||||
|
||||
enum { RIGHT = -1, CENTER, LEFT }; ///< Alignments
|
||||
|
||||
char title_[1024]; ///< Title string
|
||||
Fl_Color defcolor_, ///< Default text color
|
||||
bgcolor_, ///< Background color
|
||||
textcolor_, ///< Text color
|
||||
linkcolor_; ///< Link color
|
||||
Fl_Font textfont_; ///< Default font for text
|
||||
Fl_Fontsize textsize_; ///< Default font size
|
||||
const char *value_; ///< HTML text value
|
||||
Fl_Help_Font_Stack fstack_; ///< font stack management
|
||||
int nblocks_, ///< Number of blocks/paragraphs
|
||||
ablocks_; ///< Allocated blocks
|
||||
Fl_Help_Block *blocks_; ///< Blocks
|
||||
|
||||
Fl_Help_Func *link_; ///< Link transform function
|
||||
|
||||
int nlinks_, ///< Number of links
|
||||
alinks_; ///< Allocated links
|
||||
Fl_Help_Link *links_; ///< Links
|
||||
|
||||
int ntargets_, ///< Number of targets
|
||||
atargets_; ///< Allocated targets
|
||||
Fl_Help_Target *targets_; ///< Targets
|
||||
|
||||
char directory_[FL_PATH_MAX];///< Directory for current file
|
||||
char filename_[FL_PATH_MAX]; ///< Current filename
|
||||
int topline_, ///< Top line in document
|
||||
leftline_, ///< Lefthand position
|
||||
size_, ///< Total document length
|
||||
hsize_, ///< Maximum document width
|
||||
scrollbar_size_; ///< Size for both scrollbars
|
||||
Fl_Scrollbar scrollbar_, ///< Vertical scrollbar for document
|
||||
hscrollbar_; ///< Horizontal scrollbar
|
||||
|
||||
static int selection_first;
|
||||
static int selection_last;
|
||||
static int selection_push_first;
|
||||
static int selection_push_last;
|
||||
static int selection_drag_first;
|
||||
static int selection_drag_last;
|
||||
static int selected;
|
||||
static int draw_mode;
|
||||
static int mouse_x;
|
||||
static int mouse_y;
|
||||
static int current_pos;
|
||||
static Fl_Help_View *current_view;
|
||||
static Fl_Color hv_selection_color;
|
||||
static Fl_Color hv_selection_text_color;
|
||||
|
||||
|
||||
void initfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) { f = textfont_; s = textsize_; c = textcolor_; fstack_.init(f, s, c); }
|
||||
void pushfont(Fl_Font f, Fl_Fontsize s) {fstack_.push(f, s, textcolor_);}
|
||||
void pushfont(Fl_Font f, Fl_Fontsize s, Fl_Color c) {fstack_.push(f, s, c);}
|
||||
void popfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) {fstack_.pop(f, s, c);}
|
||||
|
||||
Fl_Help_Block *add_block(const char *s, int xx, int yy, int ww, int hh, uchar border = 0);
|
||||
void add_link(const char *n, int xx, int yy, int ww, int hh);
|
||||
void add_target(const char *n, int yy);
|
||||
static int compare_targets(const Fl_Help_Target *t0, const Fl_Help_Target *t1);
|
||||
int do_align(Fl_Help_Block *block, int line, int xx, int a, int &l);
|
||||
#if FLTK_ABI_VERSION >= 10303
|
||||
protected:
|
||||
#endif
|
||||
void draw();
|
||||
#if FLTK_ABI_VERSION >= 10303
|
||||
private:
|
||||
#endif
|
||||
void format();
|
||||
void format_table(int *table_width, int *columns, const char *table);
|
||||
void free_data();
|
||||
int get_align(const char *p, int a);
|
||||
const char *get_attr(const char *p, const char *n, char *buf, int bufsize);
|
||||
Fl_Color get_color(const char *n, Fl_Color c);
|
||||
Fl_Shared_Image *get_image(const char *name, int W, int H);
|
||||
int get_length(const char *l);
|
||||
#if FLTK_ABI_VERSION >= 10303
|
||||
public:
|
||||
#endif
|
||||
int handle(int);
|
||||
#if FLTK_ABI_VERSION >= 10303
|
||||
private:
|
||||
#endif
|
||||
|
||||
void hv_draw(const char *t, int x, int y, int entity_extra_length = 0);
|
||||
char begin_selection();
|
||||
char extend_selection();
|
||||
void end_selection(int c=0);
|
||||
void clear_global_selection();
|
||||
Fl_Help_Link *find_link(int, int);
|
||||
void follow_link(Fl_Help_Link*);
|
||||
|
||||
public:
|
||||
|
||||
Fl_Help_View(int xx, int yy, int ww, int hh, const char *l = 0);
|
||||
~Fl_Help_View();
|
||||
/** Returns the current directory for the text in the buffer. */
|
||||
const char *directory() const { if (directory_[0]) return (directory_);
|
||||
else return ((const char *)0); }
|
||||
/** Returns the current filename for the text in the buffer. */
|
||||
const char *filename() const { if (filename_[0]) return (filename_);
|
||||
else return ((const char *)0); }
|
||||
int find(const char *s, int p = 0);
|
||||
/**
|
||||
This method assigns a callback function to use when a link is
|
||||
followed or a file is loaded (via Fl_Help_View::load()) that
|
||||
requires a different file or path.
|
||||
|
||||
The callback function receives a pointer to the Fl_Help_View
|
||||
widget and the URI or full pathname for the file in question.
|
||||
It must return a pathname that can be opened as a local file or NULL:
|
||||
|
||||
\code
|
||||
const char *fn(Fl_Widget *w, const char *uri);
|
||||
\endcode
|
||||
|
||||
The link function can be used to retrieve remote or virtual
|
||||
documents, returning a temporary file that contains the actual
|
||||
data. If the link function returns NULL, the value of
|
||||
the Fl_Help_View widget will remain unchanged.
|
||||
|
||||
If the link callback cannot handle the URI scheme, it should
|
||||
return the uri value unchanged or set the value() of the widget
|
||||
before returning NULL.
|
||||
*/
|
||||
void link(Fl_Help_Func *fn) { link_ = fn; }
|
||||
int load(const char *f);
|
||||
void resize(int,int,int,int);
|
||||
/** Gets the size of the help view. */
|
||||
int size() const { return (size_); }
|
||||
void size(int W, int H) { Fl_Widget::size(W, H); }
|
||||
/** Sets the default text color. */
|
||||
void textcolor(Fl_Color c) { if (textcolor_ == defcolor_) textcolor_ = c; defcolor_ = c; }
|
||||
/** Returns the current default text color. */
|
||||
Fl_Color textcolor() const { return (defcolor_); }
|
||||
/** Sets the default text font. */
|
||||
void textfont(Fl_Font f) { textfont_ = f; format(); }
|
||||
/** Returns the current default text font. */
|
||||
Fl_Font textfont() const { return (textfont_); }
|
||||
/** Sets the default text size. */
|
||||
void textsize(Fl_Fontsize s) { textsize_ = s; format(); }
|
||||
/** Gets the default text size. */
|
||||
Fl_Fontsize textsize() const { return (textsize_); }
|
||||
/** Returns the current document title, or NULL if there is no title. */
|
||||
const char *title() { return (title_); }
|
||||
void topline(const char *n);
|
||||
void topline(int);
|
||||
/** Returns the current top line in pixels. */
|
||||
int topline() const { return (topline_); }
|
||||
void leftline(int);
|
||||
/** Gets the left position in pixels. */
|
||||
int leftline() const { return (leftline_); }
|
||||
void value(const char *val);
|
||||
/** Returns the current buffer contents. */
|
||||
const char *value() const { return (value_); }
|
||||
void clear_selection();
|
||||
void select_all();
|
||||
/**
|
||||
Gets the current size of the scrollbars' troughs, in pixels.
|
||||
|
||||
If this value is zero (default), this widget will use the
|
||||
Fl::scrollbar_size() value as the scrollbar's width.
|
||||
|
||||
\returns Scrollbar size in pixels, or 0 if the global Fl::scrollbar_size() is being used.
|
||||
\see Fl::scrollbar_size(int)
|
||||
*/
|
||||
int scrollbar_size() const {
|
||||
return(scrollbar_size_);
|
||||
}
|
||||
/**
|
||||
Sets the pixel size of the scrollbars' troughs to \p newSize, in pixels.
|
||||
|
||||
Normally you should not need this method, and should use
|
||||
Fl::scrollbar_size(int) instead to manage the size of ALL
|
||||
your widgets' scrollbars. This ensures your application
|
||||
has a consistent UI, is the default behavior, and is normally
|
||||
what you want.
|
||||
|
||||
Only use THIS method if you really need to override the global
|
||||
scrollbar size. The need for this should be rare.
|
||||
|
||||
Setting \p newSize to the special value of 0 causes the widget to
|
||||
track the global Fl::scrollbar_size(), which is the default.
|
||||
|
||||
\param[in] newSize Sets the scrollbar size in pixels.\n
|
||||
If 0 (default), scrollbar size tracks the global Fl::scrollbar_size()
|
||||
\see Fl::scrollbar_size()
|
||||
*/
|
||||
void scrollbar_size(int newSize) {
|
||||
scrollbar_size_ = newSize;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !Fl_Help_View_H
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,51 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Hold browser header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Hold_Browser widget . */
|
||||
|
||||
#ifndef Fl_Hold_Browser_H
|
||||
#define Fl_Hold_Browser_H
|
||||
|
||||
#include "Fl_Browser.H"
|
||||
|
||||
/**
|
||||
The Fl_Hold_Browser is a subclass of Fl_Browser
|
||||
which lets the user select a single item, or no items by clicking on
|
||||
the empty space. As long as the mouse button is held down the item
|
||||
pointed to by it is highlighted, and this highlighting remains on when
|
||||
the mouse button is released. Normally the callback is done when the
|
||||
user releases the mouse, but you can change this with when().
|
||||
<P>See Fl_Browser for methods to add and remove lines from the browser.
|
||||
*/
|
||||
class FL_EXPORT Fl_Hold_Browser : public Fl_Browser {
|
||||
public:
|
||||
/**
|
||||
Creates a new Fl_Hold_Browser widget using the given
|
||||
position, size, and label string. The default boxtype is FL_DOWN_BOX.
|
||||
The constructor specializes Fl_Browser() by setting the type to FL_HOLD_BROWSER.
|
||||
The destructor destroys the widget and frees all memory that has been allocated.
|
||||
*/
|
||||
Fl_Hold_Browser(int X,int Y,int W,int H,const char *L=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,36 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Horizontal fill slider header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Hor_Fill_Slider widget . */
|
||||
|
||||
#ifndef Fl_Hor_Fill_Slider_H
|
||||
#define Fl_Hor_Fill_Slider_H
|
||||
|
||||
#include "Fl_Slider.H"
|
||||
|
||||
class FL_EXPORT Fl_Hor_Fill_Slider : public Fl_Slider {
|
||||
public:
|
||||
Fl_Hor_Fill_Slider(int X,int Y,int W,int H,const char *L=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,36 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Horizontal "nice" slider header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Hor_Nice_Slider widget . */
|
||||
|
||||
#ifndef Fl_Hor_Nice_Slider_H
|
||||
#define Fl_Hor_Nice_Slider_H
|
||||
|
||||
#include "Fl_Slider.H"
|
||||
|
||||
class FL_EXPORT Fl_Hor_Nice_Slider : public Fl_Slider {
|
||||
public:
|
||||
Fl_Hor_Nice_Slider(int X,int Y,int W,int H,const char *L=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,45 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Horizontal slider header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2011 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Hor_Slider widget . */
|
||||
|
||||
#ifndef Fl_Hor_Slider_H
|
||||
#define Fl_Hor_Slider_H
|
||||
|
||||
#include "Fl_Slider.H"
|
||||
|
||||
/** Horizontal Slider class.
|
||||
|
||||
\see class Fl_Slider.
|
||||
*/
|
||||
class FL_EXPORT Fl_Hor_Slider : public Fl_Slider {
|
||||
public:
|
||||
|
||||
/**
|
||||
Creates a new Fl_Hor_Slider widget using the given position,
|
||||
size, and label string.
|
||||
*/
|
||||
Fl_Hor_Slider(int X,int Y,int W,int H,const char *l=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,36 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Horizontal value slider header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Hor_Value_Slider widget . */
|
||||
|
||||
#ifndef Fl_Hor_Value_Slider_H
|
||||
#define Fl_Hor_Value_Slider_H
|
||||
|
||||
#include "Fl_Value_Slider.H"
|
||||
|
||||
class FL_EXPORT Fl_Hor_Value_Slider : public Fl_Value_Slider {
|
||||
public:
|
||||
Fl_Hor_Value_Slider(int X,int Y,int W,int H,const char *l=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,262 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Image header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/** \file
|
||||
Fl_Image, Fl_RGB_Image classes. */
|
||||
|
||||
#ifndef Fl_Image_H
|
||||
# define Fl_Image_H
|
||||
|
||||
# include "Enumerations.H"
|
||||
#include <stdlib.h>
|
||||
|
||||
class Fl_Widget;
|
||||
class Fl_Pixmap;
|
||||
struct Fl_Menu_Item;
|
||||
struct Fl_Label;
|
||||
|
||||
|
||||
/** \enum Fl_RGB_Scaling
|
||||
The scaling algorithm to use for RGB images.
|
||||
*/
|
||||
enum Fl_RGB_Scaling {
|
||||
FL_RGB_SCALING_NEAREST = 0, ///< default RGB image scaling algorithm
|
||||
FL_RGB_SCALING_BILINEAR ///< more accurate, but slower RGB image scaling algorithm
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Base class for image caching and drawing.
|
||||
|
||||
Fl_Image is the base class used for caching and drawing all kinds of images
|
||||
in FLTK. This class keeps track of common image data such as the pixels,
|
||||
colormap, width, height, and depth. Virtual methods are used to provide
|
||||
type-specific image handling.
|
||||
|
||||
Since the Fl_Image class does not support image
|
||||
drawing by itself, calling the draw() method results in
|
||||
a box with an X in it being drawn instead.
|
||||
*/
|
||||
class FL_EXPORT Fl_Image {
|
||||
|
||||
public:
|
||||
static const int ERR_NO_IMAGE = -1;
|
||||
static const int ERR_FILE_ACCESS = -2;
|
||||
static const int ERR_FORMAT = -3;
|
||||
|
||||
private:
|
||||
int w_, h_, d_, ld_, count_;
|
||||
const char * const *data_;
|
||||
static Fl_RGB_Scaling RGB_scaling_;
|
||||
|
||||
// Forbid use of copy constructor and assign operator
|
||||
Fl_Image & operator=(const Fl_Image &);
|
||||
Fl_Image(const Fl_Image &);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
Sets the current image width in pixels.
|
||||
*/
|
||||
void w(int W) {w_ = W;}
|
||||
/**
|
||||
Sets the current image height in pixels.
|
||||
*/
|
||||
void h(int H) {h_ = H;}
|
||||
/**
|
||||
Sets the current image depth.
|
||||
*/
|
||||
void d(int D) {d_ = D;}
|
||||
/**
|
||||
Sets the current line data size in bytes.
|
||||
|
||||
Color images may contain extra data that is included after every
|
||||
line of color image data and is normally not present.
|
||||
|
||||
If \p LD is zero, then line data size is assumed to be w() * d() bytes.
|
||||
|
||||
If \p LD is non-zero, then it must be positive and larger than w() * d()
|
||||
to account for the extra data per line.
|
||||
*/
|
||||
void ld(int LD) {ld_ = LD;}
|
||||
/**
|
||||
Sets the current array pointer and count of pointers in the array.
|
||||
*/
|
||||
void data(const char * const *p, int c) {data_ = p; count_ = c;}
|
||||
void draw_empty(int X, int Y);
|
||||
|
||||
static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la);
|
||||
static void measure(const Fl_Label *lo, int &lw, int &lh);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
Returns the current image width in pixels.
|
||||
*/
|
||||
int w() const {return w_;}
|
||||
/**
|
||||
Returns the current image height in pixels.
|
||||
*/
|
||||
int h() const {return h_;}
|
||||
/**
|
||||
Returns the current image depth.
|
||||
The return value will be 0 for bitmaps, 1 for
|
||||
pixmaps, and 1 to 4 for color images.</P>
|
||||
*/
|
||||
int d() const {return d_;}
|
||||
/**
|
||||
Returns the current line data size in bytes.
|
||||
\see ld(int)
|
||||
*/
|
||||
int ld() const {return ld_;}
|
||||
/**
|
||||
The count() method returns the number of data values
|
||||
associated with the image. The value will be 0 for images with
|
||||
no associated data, 1 for bitmap and color images, and greater
|
||||
than 2 for pixmap images.
|
||||
*/
|
||||
int count() const {return count_;}
|
||||
/**
|
||||
Returns a pointer to the current image data array.
|
||||
Use the count() method to find the size of the data array.
|
||||
*/
|
||||
const char * const *data() const {return data_;}
|
||||
int fail();
|
||||
Fl_Image(int W, int H, int D);
|
||||
virtual ~Fl_Image();
|
||||
virtual Fl_Image *copy(int W, int H);
|
||||
/**
|
||||
The copy() method creates a copy of the specified
|
||||
image. If the width and height are provided, the image is
|
||||
resized to the specified size. The image should be deleted (or in
|
||||
the case of Fl_Shared_Image, released) when you are done
|
||||
with it.
|
||||
*/
|
||||
Fl_Image *copy() { return copy(w(), h()); }
|
||||
virtual void color_average(Fl_Color c, float i);
|
||||
/**
|
||||
The inactive() method calls
|
||||
color_average(FL_BACKGROUND_COLOR, 0.33f) to produce
|
||||
an image that appears grayed out.
|
||||
|
||||
An internal copy is made of the original image before
|
||||
changes are applied, to avoid modifying the original image.
|
||||
*/
|
||||
void inactive() { color_average(FL_GRAY, .33f); }
|
||||
virtual void desaturate();
|
||||
virtual void label(Fl_Widget*w);
|
||||
virtual void label(Fl_Menu_Item*m);
|
||||
/**
|
||||
Draws the image with a bounding box.
|
||||
Arguments <tt>X,Y,W,H</tt> specify
|
||||
a bounding box for the image, with the origin
|
||||
(upper-left corner) of the image offset by the \c cx
|
||||
and \c cy arguments.
|
||||
|
||||
In other words: <tt>fl_push_clip(X,Y,W,H)</tt> is applied,
|
||||
the image is drawn with its upper-left corner at <tt>X-cx,Y-cy</tt> and its own width and height,
|
||||
<tt>fl_pop_clip</tt><tt>()</tt> is applied.
|
||||
*/
|
||||
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
|
||||
/**
|
||||
Draws the image.
|
||||
This form specifies the upper-lefthand corner of the image.
|
||||
*/
|
||||
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
|
||||
virtual void uncache();
|
||||
|
||||
// set RGB image scaling method
|
||||
static void RGB_scaling(Fl_RGB_Scaling);
|
||||
|
||||
// get RGB image scaling method
|
||||
static Fl_RGB_Scaling RGB_scaling();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
The Fl_RGB_Image class supports caching and drawing
|
||||
of full-color images with 1 to 4 channels of color information.
|
||||
Images with an even number of channels are assumed to contain
|
||||
alpha information, which is used to blend the image with the
|
||||
contents of the screen.
|
||||
|
||||
Fl_RGB_Image is defined in
|
||||
<FL/Fl_Image.H>, however for compatibility reasons
|
||||
<FL/Fl_RGB_Image.H> should be included.
|
||||
*/
|
||||
class FL_EXPORT Fl_RGB_Image : public Fl_Image {
|
||||
friend class Fl_Quartz_Graphics_Driver;
|
||||
friend class Fl_GDI_Graphics_Driver;
|
||||
friend class Fl_GDI_Printer_Graphics_Driver;
|
||||
friend class Fl_Xlib_Graphics_Driver;
|
||||
static size_t max_size_;
|
||||
public:
|
||||
|
||||
/** Points to the start of the object's data array
|
||||
*/
|
||||
const uchar *array;
|
||||
/** If non-zero, the object's data array is delete[]'d when deleting the object.
|
||||
*/
|
||||
int alloc_array;
|
||||
|
||||
private:
|
||||
|
||||
#if defined(__APPLE__) || defined(WIN32)
|
||||
void *id_; // for internal use
|
||||
void *mask_; // for internal use (mask bitmap)
|
||||
#else
|
||||
unsigned id_; // for internal use
|
||||
unsigned mask_; // for internal use (mask bitmap)
|
||||
#endif // __APPLE__ || WIN32
|
||||
|
||||
public:
|
||||
|
||||
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0);
|
||||
Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY);
|
||||
virtual ~Fl_RGB_Image();
|
||||
virtual Fl_Image *copy(int W, int H);
|
||||
Fl_Image *copy() { return copy(w(), h()); }
|
||||
virtual void color_average(Fl_Color c, float i);
|
||||
virtual void desaturate();
|
||||
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
|
||||
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
|
||||
virtual void label(Fl_Widget*w);
|
||||
virtual void label(Fl_Menu_Item*m);
|
||||
virtual void uncache();
|
||||
/** Sets the maximum allowed image size in bytes when creating an Fl_RGB_Image object.
|
||||
|
||||
The image size in bytes of an Fl_RGB_Image object is the value of the product w() * h() * d().
|
||||
If this product exceeds size, the created object of a derived class of Fl_RGB_Image
|
||||
won't be loaded with the image data.
|
||||
This does not apply to direct RGB image creation with
|
||||
Fl_RGB_Image::Fl_RGB_Image(const uchar *bits, int W, int H, int D, int LD).
|
||||
The default max_size() value is essentially infinite.
|
||||
*/
|
||||
static void max_size(size_t size) { max_size_ = size;}
|
||||
/** Returns the maximum allowed image size in bytes when creating an Fl_RGB_Image object.
|
||||
|
||||
\sa void Fl_RGB_Image::max_size(size_t)
|
||||
*/
|
||||
static size_t max_size() {return max_size_;}
|
||||
};
|
||||
|
||||
#endif // !Fl_Image_H
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,99 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Draw-to-image code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2014 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
#ifndef Fl_Image_Surface_H
|
||||
#define Fl_Image_Surface_H
|
||||
|
||||
#include <FL/Fl_Copy_Surface.H>
|
||||
#include <FL/Fl_Image.H>
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
|
||||
|
||||
/** Directs all graphics requests to an Fl_Image.
|
||||
|
||||
After creation of an Fl_Image_Surface object, call set_current() on it, and all subsequent graphics requests
|
||||
will be recorded in the image. It's possible to draw widgets (using Fl_Image_Surface::draw())
|
||||
or to use any of the \ref fl_drawings or the \ref fl_attributes.
|
||||
Finally, call image() on the object to obtain a newly allocated Fl_RGB_Image object.
|
||||
<br> Fl_GL_Window objects can be drawn in the image as well.
|
||||
|
||||
<br> Usage example:
|
||||
\code
|
||||
Fl_Widget *g = ...; // a widget you want to draw in an image
|
||||
Fl_Image_Surface *img_surf = new Fl_Image_Surface(g->w(), g->h()); // create an Fl_Image_Surface object
|
||||
img_surf->set_current(); // direct graphics requests to the image
|
||||
fl_color(FL_WHITE); fl_rectf(0, 0, g->w(), g->h()); // draw a white background
|
||||
img_surf->draw(g); // draw the g widget in the image
|
||||
Fl_RGB_Image* image = img_surf->image(); // get the resulting image
|
||||
delete img_surf; // delete the img_surf object
|
||||
Fl_Display_Device::display_device()->set_current(); // direct graphics requests back to the display
|
||||
\endcode
|
||||
*/
|
||||
class FL_EXPORT Fl_Image_Surface : public Fl_Surface_Device {
|
||||
private:
|
||||
void prepare_(int w, int h, int highres);
|
||||
Fl_Offscreen offscreen;
|
||||
int width;
|
||||
int height;
|
||||
Fl_Paged_Device *helper;
|
||||
#ifdef __APPLE__
|
||||
#elif defined(WIN32)
|
||||
HDC _sgc;
|
||||
Window _sw;
|
||||
Fl_Surface_Device *_ss;
|
||||
int _savedc;
|
||||
#else
|
||||
Fl_Surface_Device *previous;
|
||||
Window pre_window;
|
||||
GC gc;
|
||||
#endif
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
#if FLTK_ABI_VERSION >= 10304 || defined(FL_DOXYGEN)
|
||||
Fl_Image_Surface(int w, int h, int highres = 0);
|
||||
#else
|
||||
Fl_Image_Surface(int w, int h, int highres);
|
||||
Fl_Image_Surface(int w, int h);
|
||||
#endif
|
||||
~Fl_Image_Surface();
|
||||
void set_current();
|
||||
void draw(Fl_Widget*, int delta_x = 0, int delta_y = 0);
|
||||
void draw_decorated_window(Fl_Window* win, int delta_x = 0, int delta_y = 0);
|
||||
Fl_RGB_Image *image();
|
||||
Fl_Shared_Image *highres_image();
|
||||
};
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* Mac class to implement translate()/untranslate() for a flipped bitmap graphics context */
|
||||
class FL_EXPORT Fl_Quartz_Flipped_Surface_ : public Fl_Quartz_Surface_ {
|
||||
public:
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
Fl_Quartz_Flipped_Surface_(int w, int h);
|
||||
void translate(int x, int y);
|
||||
void untranslate();
|
||||
virtual ~Fl_Quartz_Flipped_Surface_() {};
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // Fl_Image_Surface_H
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,269 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Input header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Input widget . */
|
||||
|
||||
#ifndef Fl_Input_H
|
||||
#define Fl_Input_H
|
||||
|
||||
#include "Fl_Input_.H"
|
||||
|
||||
/**
|
||||
This is the FLTK text input widget. It displays a single line
|
||||
of text and lets the user edit it. Normally it is drawn with an
|
||||
inset box and a white background. The text may contain any
|
||||
characters, and will correctly display any UTF text, using
|
||||
^X notation for unprintable control characters. It assumes the
|
||||
font can draw any characters of the used scripts, which is true
|
||||
for standard fonts under MSWindows and Mac OS X.
|
||||
Characters can be input using the keyboard or the character palette/map.
|
||||
Character composition is done using dead keys and/or a compose
|
||||
key as defined by the operating system.
|
||||
<P>
|
||||
<!-- DON'T use the class name in the caption, or doxygen 1.8.x will fail. -->
|
||||
<TABLE WIDTH="90%" BORDER="1" SUMMARY="Fl_Input keyboard and mouse bindings.">
|
||||
<CAPTION ALIGN="TOP">Keyboard and mouse bindings.</CAPTION>
|
||||
<TR><TD NOWRAP="NOWRAP" WIDTH="1%">
|
||||
<B>Mouse button 1</B>
|
||||
</TD><TD>
|
||||
Moves the cursor to this point.
|
||||
Drag selects characters.
|
||||
Double click selects words.
|
||||
Triple click selects all line.
|
||||
Shift+click extends the selection.
|
||||
When you select text it is automatically copied to the selection buffer.
|
||||
</TD></TR><TR><TD NOWRAP="NOWRAP">
|
||||
<B>Mouse button 2</B>
|
||||
</TD><TD>
|
||||
Insert the selection buffer at the point clicked.
|
||||
You can also select a region and replace it with the selection buffer
|
||||
by selecting the region with mouse button 2.
|
||||
</TD></TR><TR><TD NOWRAP="NOWRAP">
|
||||
<B>Mouse button 3</B>
|
||||
</TD><TD>
|
||||
Currently acts like button 1.
|
||||
</TD></TR><TR><TD NOWRAP="NOWRAP">
|
||||
<B>Backspace</B>
|
||||
</TD><TD>
|
||||
Deletes one character to the left, or deletes the selected region.
|
||||
</TD></TR><TR><TD NOWRAP="NOWRAP">
|
||||
<B>Delete</B>
|
||||
</TD><TD>
|
||||
Deletes one character to the right, or deletes the selected region.
|
||||
Combine with Shift for equivalent of ^X (copy+cut).
|
||||
</TD></TR><TR><TD NOWRAP="NOWRAP">
|
||||
<B>Enter</b>
|
||||
</TD><TD>
|
||||
May cause the callback, see when().
|
||||
</TD></TR></TABLE>
|
||||
|
||||
<P>
|
||||
|
||||
<TABLE WIDTH="90%" BORDER="1" SUMMARY="Fl_Input platform specific keyboard bindings.">
|
||||
<CAPTION ALIGN="TOP">Platform specific keyboard bindings.</CAPTION>
|
||||
<TR>
|
||||
<TD NOWRAP="NOWRAP" WIDTH="1%"><B> Windows/Linux </B></TD>
|
||||
<TD NOWRAP="NOWRAP" WIDTH="1%"><B> Mac </B></TD>
|
||||
<TD NOWRAP="NOWRAP" ><B> Function </B></TD>
|
||||
|
||||
</TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> ^A </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Command-A </B></TD>
|
||||
<TD>
|
||||
<B>Selects all text in the widget.</B>
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> ^C </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Command-C </B></TD>
|
||||
<TD>
|
||||
<B>Copy the current selection to the clipboard.</B>
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> ^I </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> ^I </B></TD>
|
||||
<TD>
|
||||
<B>Insert a tab.</B>
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> ^J </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> ^J </B></TD>
|
||||
<TD>
|
||||
<B>Insert a Line Feed.</B> <BR>
|
||||
(Similar to literal 'Enter' character)
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> ^L </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> ^L </B></TD>
|
||||
<TD>
|
||||
<B>Insert a Form Feed.</B>
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> ^M </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> ^M </B></TD>
|
||||
<TD>
|
||||
<B>Insert a Carriage Return.</B>
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> ^V,<BR>Shift-Insert </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Command-V </B></TD>
|
||||
<TD>
|
||||
<B>Paste the clipboard.</B> <BR>
|
||||
(Macs keyboards don't have "Insert" keys,
|
||||
but if they did, Shift-Insert would work)
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> ^X,<BR>Shift-Delete </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Command-X,<BR>Shift-Delete </B></TD>
|
||||
<TD>
|
||||
<B>Cut.</B> <BR>
|
||||
Copy the selection to the clipboard and delete it.
|
||||
(If there's no selection, Shift-Delete acts like Delete)
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> ^Z </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Command-Z </B></TD>
|
||||
<TD>
|
||||
<B>Undo.</B> <BR>
|
||||
This is a single-level undo mechanism, but all adjacent
|
||||
deletions and insertions are concatenated into a single "undo".
|
||||
Often this will undo a lot more than you expected.
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> Shift-^Z </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Shift-Command-Z </B></TD>
|
||||
<TD>
|
||||
<B>Redo.</B> <BR>
|
||||
Currently same behavior as ^Z.
|
||||
Reserved for future multilevel undo/redo.
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> Arrow Keys </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Arrow Keys </B></TD>
|
||||
<TD>
|
||||
<B>Standard cursor movement.</B> <BR>
|
||||
Can be combined with Shift to extend selection.
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> Home </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Command-Up,<BR>Command-Left </B></TD>
|
||||
<TD>
|
||||
<B>Move to start of line.</B> <BR>
|
||||
Can be combined with Shift to extend selection.
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> End </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Command-Down,<BR>Command-Right </B></TD>
|
||||
<TD>
|
||||
<B>Move to end of line.</B> <BR>
|
||||
Can be combined with Shift to extend selection.
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B>Ctrl-Home</B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B>Command-Up,<BR>Command-PgUp,<BR>Ctrl-Left</B></TD>
|
||||
<TD>
|
||||
<B>Move to top of document/field.</B> <BR>
|
||||
In single line input, moves to start of line.
|
||||
In multiline input, moves to start of top line.
|
||||
Can be combined with Shift to extend selection.
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> Ctrl-End </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Command-End,<BR>Command-PgDn,<BR>Ctrl-Right</B></TD>
|
||||
<TD>
|
||||
<B>Move to bottom of document/field.</B> <BR>
|
||||
In single line input, moves to end of line.
|
||||
In multiline input, moves to end of last line.
|
||||
Can be combined with Shift to extend selection.
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> Ctrl-Left </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Alt-Left </B></TD>
|
||||
<TD>
|
||||
<B>Word left.</B> <BR>
|
||||
Can be combined with Shift to extend selection.
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> Ctrl-Right </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Alt-Right </B></TD>
|
||||
<TD>
|
||||
<B>Word right.</B> <BR>
|
||||
Can be combined with Shift to extend selection.
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> Ctrl-Backspace </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Alt-Backspace </B></TD>
|
||||
<TD>
|
||||
<B>Delete word left.</B>
|
||||
|
||||
</TD></TR><TR>
|
||||
<TD NOWRAP="NOWRAP"><B> Ctrl-Delete </B></TD>
|
||||
<TD NOWRAP="NOWRAP"><B> Alt-Delete </B></TD>
|
||||
<TD>
|
||||
<B>Delete word right.</B>
|
||||
|
||||
</TD></TR></TABLE>
|
||||
*/
|
||||
class FL_EXPORT Fl_Input : public Fl_Input_ {
|
||||
int handle_key();
|
||||
int shift_position(int p);
|
||||
int shift_up_down_position(int p);
|
||||
void handle_mouse(int keepmark=0);
|
||||
|
||||
// Private keyboard functions
|
||||
int kf_lines_up(int repeat_num);
|
||||
int kf_lines_down(int repeat_num);
|
||||
int kf_page_up();
|
||||
int kf_page_down();
|
||||
int kf_insert_toggle();
|
||||
int kf_delete_word_right();
|
||||
int kf_delete_word_left();
|
||||
int kf_delete_sol();
|
||||
int kf_delete_eol();
|
||||
int kf_delete_char_right();
|
||||
int kf_delete_char_left();
|
||||
int kf_move_sol();
|
||||
int kf_move_eol();
|
||||
int kf_clear_eol();
|
||||
int kf_move_char_left();
|
||||
int kf_move_char_right();
|
||||
int kf_move_word_left();
|
||||
int kf_move_word_right();
|
||||
int kf_move_up_and_sol();
|
||||
int kf_move_down_and_eol();
|
||||
int kf_top();
|
||||
int kf_bottom();
|
||||
int kf_select_all();
|
||||
int kf_undo();
|
||||
int kf_redo();
|
||||
int kf_copy();
|
||||
int kf_paste();
|
||||
int kf_copy_cut();
|
||||
|
||||
protected:
|
||||
void draw();
|
||||
public:
|
||||
int handle(int);
|
||||
Fl_Input(int,int,int,int,const char * = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,499 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Input base class header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2015 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Input_ widget . */
|
||||
|
||||
#ifndef Fl_Input__H
|
||||
#define Fl_Input__H
|
||||
|
||||
#ifndef Fl_Widget_H
|
||||
#include "Fl_Widget.H"
|
||||
#endif
|
||||
|
||||
#define FL_NORMAL_INPUT 0
|
||||
#define FL_FLOAT_INPUT 1
|
||||
#define FL_INT_INPUT 2
|
||||
#define FL_HIDDEN_INPUT 3
|
||||
#define FL_MULTILINE_INPUT 4
|
||||
#define FL_SECRET_INPUT 5
|
||||
#define FL_INPUT_TYPE 7
|
||||
#define FL_INPUT_READONLY 8
|
||||
#define FL_NORMAL_OUTPUT (FL_NORMAL_INPUT | FL_INPUT_READONLY)
|
||||
#define FL_MULTILINE_OUTPUT (FL_MULTILINE_INPUT | FL_INPUT_READONLY)
|
||||
#define FL_INPUT_WRAP 16
|
||||
#define FL_MULTILINE_INPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_WRAP)
|
||||
#define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_READONLY | FL_INPUT_WRAP)
|
||||
|
||||
/**
|
||||
This class provides a low-overhead text input field.
|
||||
|
||||
This is a virtual base class below Fl_Input. It has all
|
||||
the same interfaces, but lacks the handle() and
|
||||
draw() method. You may want to subclass it if you are
|
||||
one of those people who likes to change how the editing keys
|
||||
work. It may also be useful for adding scrollbars
|
||||
to the input field.
|
||||
|
||||
This can act like any of the subclasses of Fl_Input, by
|
||||
setting type() to one of the following values:
|
||||
|
||||
\code
|
||||
#define FL_NORMAL_INPUT 0
|
||||
#define FL_FLOAT_INPUT 1
|
||||
#define FL_INT_INPUT 2
|
||||
#define FL_MULTILINE_INPUT 4
|
||||
#define FL_SECRET_INPUT 5
|
||||
#define FL_INPUT_TYPE 7
|
||||
#define FL_INPUT_READONLY 8
|
||||
#define FL_NORMAL_OUTPUT (FL_NORMAL_INPUT | FL_INPUT_READONLY)
|
||||
#define FL_MULTILINE_OUTPUT (FL_MULTILINE_INPUT | FL_INPUT_READONLY)
|
||||
#define FL_INPUT_WRAP 16
|
||||
#define FL_MULTILINE_INPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_WRAP)
|
||||
#define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_READONLY | FL_INPUT_WRAP)
|
||||
\endcode
|
||||
|
||||
All variables that represent an index into a text buffer are byte-oriented,
|
||||
not character oriented, counting from 0 (at or before the first character)
|
||||
to size() (at the end of the buffer, after the last byte). Since UTF-8
|
||||
characters can be up to six bytes long, simply incrementing such an index
|
||||
will not reliably advance to the next character in the text buffer.
|
||||
|
||||
Indices and pointers into the text buffer should always point at a 7 bit ASCII
|
||||
character or the beginning of a UTF-8 character sequence. Behavior for false
|
||||
UTF-8 sequences and pointers into the middle of a sequence are undefined.
|
||||
|
||||
\see Fl_Text_Display, Fl_Text_Editor for more powerful text handling widgets
|
||||
|
||||
\internal
|
||||
When porting this widget from ASCII to UTF-8, previously legal pointers into
|
||||
the text of this widget can become illegal by pointing into the middle of
|
||||
a UTF-8 sequence. This is not a big problem for Fl_Input_ because all code
|
||||
in this module is quite tolerant. It could be problematic though when deriving
|
||||
from this class because no feedback for illegal pointers is given. Additionally,
|
||||
a careless "copy" call can put partial UTF-8 sequences into the clipboard.
|
||||
|
||||
None of these issues should be disastrous. Nevertheless, we should
|
||||
discuss how FLTK should handle false UTF-8 sequences and pointers.
|
||||
*/
|
||||
class FL_EXPORT Fl_Input_ : public Fl_Widget {
|
||||
|
||||
/** \internal Storage for the text field. */
|
||||
const char* value_;
|
||||
|
||||
/** \internal Buffer memory for expanded text. \see expand() */
|
||||
char* buffer;
|
||||
|
||||
/** \internal Size of text in bytes in the \p value_ field. */
|
||||
int size_;
|
||||
|
||||
/** \internal Current size of internal value() buffer in bytes. */
|
||||
int bufsize;
|
||||
|
||||
/** \internal Position of the cursor in the document. */
|
||||
int position_;
|
||||
|
||||
/** \internal Position of the other end of the selected text.
|
||||
If \p position_ equals \p mark_, no text is selected */
|
||||
int mark_;
|
||||
|
||||
/** \internal Behavior of Tab key in multiline input widget.
|
||||
If enabled (default) Tab causes focus nav, otherwise Tab is inserted
|
||||
as a character. */
|
||||
int tab_nav_;
|
||||
|
||||
/** \internal Offset to text origin within widget bounds */
|
||||
int xscroll_, yscroll_;
|
||||
|
||||
/** \internal Minimal update pointer. Display requires redraw from here to the end
|
||||
of the buffer. */
|
||||
int mu_p;
|
||||
|
||||
/** \internal Maximum number of (UTF-8) characters a user can input. */
|
||||
int maximum_size_;
|
||||
|
||||
/** \internal Shortcut key that will fetch focus for this widget. */
|
||||
int shortcut_;
|
||||
|
||||
/** \internal This is set if no text but only the cursor needs updating. */
|
||||
uchar erase_cursor_only;
|
||||
|
||||
/** \internal The font used for the entire text. */
|
||||
Fl_Font textfont_;
|
||||
|
||||
/** \internal Height of the font used for the entire text. */
|
||||
Fl_Fontsize textsize_;
|
||||
|
||||
/** \internal color of the entire text */
|
||||
Fl_Color textcolor_;
|
||||
|
||||
/** \internal color of the text cursor */
|
||||
Fl_Color cursor_color_;
|
||||
|
||||
/** \internal Horizontal cursor position in pixels while moving up or down. */
|
||||
static double up_down_pos;
|
||||
|
||||
/** \internal Flag to remember last cursor move. */
|
||||
static int was_up_down;
|
||||
|
||||
/* Convert a given text segment into the text that will be rendered on screen. */
|
||||
const char* expand(const char*, char*) const;
|
||||
|
||||
/* Calculates the width in pixels of part of a text buffer. */
|
||||
double expandpos(const char*, const char*, const char*, int*) const;
|
||||
|
||||
/* Mark a range of characters for update. */
|
||||
void minimal_update(int, int);
|
||||
|
||||
/* Mark a range of characters for update. */
|
||||
void minimal_update(int p);
|
||||
|
||||
/* Copy the value from a possibly static entry into the internal buffer. */
|
||||
void put_in_buffer(int newsize);
|
||||
|
||||
/* Set the current font and font size. */
|
||||
void setfont() const;
|
||||
|
||||
protected:
|
||||
|
||||
/* Find the start of a word. */
|
||||
int word_start(int i) const;
|
||||
|
||||
/* Find the end of a word. */
|
||||
int word_end(int i) const;
|
||||
|
||||
/* Find the start of a line. */
|
||||
int line_start(int i) const;
|
||||
|
||||
/* Find the end of a line. */
|
||||
int line_end(int i) const;
|
||||
|
||||
/* Draw the text in the passed bounding box. */
|
||||
void drawtext(int, int, int, int);
|
||||
|
||||
/* Move the cursor to the column given by up_down_pos. */
|
||||
int up_down_position(int, int keepmark=0);
|
||||
|
||||
/* Handle mouse clicks and mouse moves. */
|
||||
void handle_mouse(int, int, int, int, int keepmark=0);
|
||||
|
||||
/* Handle all kinds of text field related events. */
|
||||
int handletext(int e, int, int, int, int);
|
||||
|
||||
/* Check the when() field and do a callback if indicated. */
|
||||
void maybe_do_callback();
|
||||
|
||||
/** \internal Horizontal offset of text to left edge of widget. */
|
||||
int xscroll() const {return xscroll_;}
|
||||
|
||||
/** \internal Vertical offset of text to top edge of widget. */
|
||||
int yscroll() const {return yscroll_;}
|
||||
void yscroll(int yOffset) { yscroll_ = yOffset; damage(FL_DAMAGE_EXPOSE);}
|
||||
|
||||
/* Return the number of lines displayed on a single page. */
|
||||
int linesPerPage();
|
||||
|
||||
public:
|
||||
|
||||
/* Change the size of the widget. */
|
||||
void resize(int, int, int, int);
|
||||
|
||||
/* Constructor */
|
||||
Fl_Input_(int, int, int, int, const char* = 0);
|
||||
|
||||
/* Destructor */
|
||||
~Fl_Input_();
|
||||
|
||||
/* Changes the widget text. */
|
||||
int value(const char*);
|
||||
|
||||
/* Changes the widget text. */
|
||||
int value(const char*, int);
|
||||
|
||||
/* Changes the widget text. */
|
||||
int static_value(const char*);
|
||||
|
||||
/* Changes the widget text. */
|
||||
int static_value(const char*, int);
|
||||
|
||||
/**
|
||||
Returns the text displayed in the widget.
|
||||
|
||||
This function returns the current value, which is a pointer
|
||||
to the internal buffer and is valid only until the next event is
|
||||
handled.
|
||||
|
||||
\return pointer to an internal buffer - do not free() this
|
||||
\see Fl_Input_::value(const char*)
|
||||
*/
|
||||
const char* value() const {return value_;}
|
||||
|
||||
/* Returns the character at index \p i. */
|
||||
Fl_Char index(int i) const;
|
||||
|
||||
/**
|
||||
Returns the number of bytes in value().
|
||||
|
||||
This may be greater than <tt>strlen(value())</tt> if there are
|
||||
\c nul characters in the text.
|
||||
|
||||
\return number of bytes in the text
|
||||
*/
|
||||
int size() const {return size_;}
|
||||
|
||||
/** Sets the width and height of this widget.
|
||||
\param [in] W, H new width and height
|
||||
\see Fl_Widget::size(int, int) */
|
||||
void size(int W, int H) { Fl_Widget::size(W, H); }
|
||||
|
||||
/** Gets the maximum length of the input field in characters.
|
||||
\see maximum_size(int). */
|
||||
int maximum_size() const {return maximum_size_;}
|
||||
|
||||
/** Sets the maximum length of the input field in characters.
|
||||
|
||||
This limits the number of <b>characters</b> that can be inserted
|
||||
in the widget.
|
||||
|
||||
Since FLTK 1.3 this is different than the buffer size, since one
|
||||
character can be more than one byte in UTF-8 encoding. In FLTK 1.1
|
||||
this was the same (one byte = one character).
|
||||
*/
|
||||
void maximum_size(int m) {maximum_size_ = m;}
|
||||
|
||||
/** Gets the position of the text cursor.
|
||||
\return the cursor position as an index in the range 0..size()
|
||||
\see position(int, int)
|
||||
*/
|
||||
int position() const {return position_;}
|
||||
|
||||
/** Gets the current selection mark.
|
||||
\return index into the text */
|
||||
int mark() const {return mark_;}
|
||||
|
||||
/* Sets the index for the cursor and mark. */
|
||||
int position(int p, int m);
|
||||
|
||||
/** Sets the cursor position and mark.
|
||||
position(n) is the same as <tt>position(n, n)</tt>.
|
||||
\param p new index for cursor and mark
|
||||
\return 0 if no positions changed
|
||||
\see position(int, int), position(), mark(int)
|
||||
*/
|
||||
int position(int p) {return position(p, p);}
|
||||
|
||||
/** Sets the current selection mark.
|
||||
mark(n) is the same as <tt>position(position(),n)</tt>.
|
||||
\param m new index of the mark
|
||||
\return 0 if the mark did not change
|
||||
\see position(), position(int, int) */
|
||||
int mark(int m) {return position(position(), m);}
|
||||
|
||||
/* Deletes text from \p b to \p e and inserts the new string \p text. */
|
||||
int replace(int b, int e, const char *text, int ilen=0);
|
||||
|
||||
/**
|
||||
Deletes the current selection.
|
||||
|
||||
This function deletes the currently selected text
|
||||
\e without storing it in the clipboard. To use the clipboard,
|
||||
you may call copy() first or copy_cuts() after
|
||||
this call.
|
||||
|
||||
\return 0 if no data was copied
|
||||
*/
|
||||
int cut() {return replace(position(), mark(), 0);}
|
||||
|
||||
/**
|
||||
Deletes the next \p n bytes rounded to characters before or after the cursor.
|
||||
|
||||
This function deletes the currently selected text
|
||||
\e without storing it in the clipboard. To use the clipboard,
|
||||
you may call copy() first or copy_cuts() after
|
||||
this call.
|
||||
|
||||
\param n number of bytes rounded to full characters and clamped to the buffer.
|
||||
A negative number will cut characters to the left of the cursor.
|
||||
\return 0 if no data was copied
|
||||
*/
|
||||
int cut(int n) {return replace(position(), position()+n, 0);}
|
||||
|
||||
/**
|
||||
Deletes all characters between index \p a and \p b.
|
||||
|
||||
This function deletes the currently selected text
|
||||
\e without storing it in the clipboard. To use the clipboard,
|
||||
you may call copy() first or copy_cuts() after
|
||||
this call.
|
||||
|
||||
\param a, b range of bytes rounded to full characters and clamped to the buffer
|
||||
\return 0 if no data was copied
|
||||
*/
|
||||
int cut(int a, int b) {return replace(a, b, 0);}
|
||||
|
||||
/**
|
||||
Inserts text at the cursor position.
|
||||
|
||||
This function inserts the string in \p t at the cursor
|
||||
position() and moves the new position and mark to
|
||||
the end of the inserted text.
|
||||
|
||||
\param [in] t text that will be inserted
|
||||
\param [in] l length of text, or 0 if the string is terminated by \c nul.
|
||||
\return 0 if no text was inserted
|
||||
*/
|
||||
int insert(const char* t, int l=0){return replace(position_, mark_, t, l);}
|
||||
|
||||
/* Put the current selection into the clipboard. */
|
||||
int copy(int clipboard);
|
||||
|
||||
/* Undo previous changes to the text buffer. */
|
||||
int undo();
|
||||
|
||||
/* Copy the yank buffer to the clipboard. */
|
||||
int copy_cuts();
|
||||
|
||||
/** Return the shortcut key associated with this widget.
|
||||
\return shortcut keystroke
|
||||
\see Fl_Button::shortcut() */
|
||||
int shortcut() const {return shortcut_;}
|
||||
|
||||
/**
|
||||
Sets the shortcut key associated with this widget.
|
||||
Pressing the shortcut key gives text editing focus to this widget.
|
||||
\param [in] s new shortcut keystroke
|
||||
\see Fl_Button::shortcut()
|
||||
*/
|
||||
void shortcut(int s) {shortcut_ = s;}
|
||||
|
||||
/** Gets the font of the text in the input field.
|
||||
\return the current Fl_Font index */
|
||||
Fl_Font textfont() const {return textfont_;}
|
||||
|
||||
/** Sets the font of the text in the input field.
|
||||
The text font defaults to \c FL_HELVETICA.
|
||||
\param [in] s the new text font */
|
||||
void textfont(Fl_Font s) {textfont_ = s;}
|
||||
|
||||
/** Gets the size of the text in the input field.
|
||||
\return the text height in pixels */
|
||||
Fl_Fontsize textsize() const {return textsize_;}
|
||||
|
||||
/** Sets the size of the text in the input field.
|
||||
The text height defaults to \c FL_NORMAL_SIZE.
|
||||
\param [in] s the new font height in pixel units */
|
||||
void textsize(Fl_Fontsize s) {textsize_ = s;}
|
||||
|
||||
/** Gets the color of the text in the input field.
|
||||
\return the text color
|
||||
\see textcolor(Fl_Color) */
|
||||
Fl_Color textcolor() const {return textcolor_;}
|
||||
|
||||
/** Sets the color of the text in the input field.
|
||||
The text color defaults to \c FL_FOREGROUND_COLOR.
|
||||
\param [in] n new text color
|
||||
\see textcolor() */
|
||||
void textcolor(Fl_Color n) {textcolor_ = n;}
|
||||
|
||||
/** Gets the color of the cursor.
|
||||
\return the current cursor color */
|
||||
Fl_Color cursor_color() const {return cursor_color_;}
|
||||
|
||||
/** Sets the color of the cursor.
|
||||
The default color for the cursor is \c FL_BLACK.
|
||||
\param [in] n the new cursor color */
|
||||
void cursor_color(Fl_Color n) {cursor_color_ = n;}
|
||||
|
||||
/** Gets the input field type.
|
||||
\return the current input type */
|
||||
int input_type() const {return type() & FL_INPUT_TYPE; }
|
||||
|
||||
/** Sets the input field type.
|
||||
A redraw() is required to reformat the input field.
|
||||
\param [in] t new input type */
|
||||
void input_type(int t) { type((uchar)(t | readonly())); }
|
||||
|
||||
/** Gets the read-only state of the input field.
|
||||
\return non-zero if this widget is read-only */
|
||||
int readonly() const { return type() & FL_INPUT_READONLY; }
|
||||
|
||||
/** Sets the read-only state of the input field.
|
||||
\param [in] b if \p b is 0, the text in this widget can be edited by the user */
|
||||
void readonly(int b) { if (b) type((uchar)(type() | FL_INPUT_READONLY));
|
||||
else type((uchar)(type() & ~FL_INPUT_READONLY)); }
|
||||
|
||||
/**
|
||||
Gets the word wrapping state of the input field.
|
||||
Word wrap is only functional with multi-line input fields.
|
||||
*/
|
||||
int wrap() const { return type() & FL_INPUT_WRAP; }
|
||||
|
||||
/**
|
||||
Sets the word wrapping state of the input field.
|
||||
Word wrap is only functional with multi-line input fields.
|
||||
*/
|
||||
void wrap(int b) { if (b) type((uchar)(type() | FL_INPUT_WRAP));
|
||||
else type((uchar)(type() & ~FL_INPUT_WRAP)); }
|
||||
|
||||
/**
|
||||
Sets whether the Tab key does focus navigation,
|
||||
or inserts tab characters into Fl_Multiline_Input.
|
||||
|
||||
By default this flag is enabled to provide the 'normal' behavior
|
||||
most users expect; Tab navigates focus to the next widget.
|
||||
To inserting an actual Tab character, users can use Ctrl-I
|
||||
or copy/paste.
|
||||
|
||||
Disabling this flag gives the old FLTK behavior where Tab
|
||||
inserts a tab character into the text field, in which case
|
||||
only the mouse can be used to navigate to the next field.
|
||||
|
||||
History: This flag was provided for backwards support of FLTK's old 1.1.x
|
||||
behavior where Tab inserts a tab character instead of navigating
|
||||
focus to the next widget. This behavior was unique to Fl_Multiline_Input.
|
||||
With the advent of Fl_Text_Editor, this old behavior has been deprecated.
|
||||
|
||||
\param [in] val If \p val is 1, Tab advances focus (default).<BR>
|
||||
If \p val is 0, Tab inserts a tab character (old FLTK behavior).
|
||||
|
||||
\see tab_nav(), Fl::OPTION_ARROW_FOCUS.
|
||||
*/
|
||||
void tab_nav(int val) {
|
||||
tab_nav_ = val;
|
||||
}
|
||||
|
||||
/**
|
||||
Gets whether the Tab key causes focus navigation in multiline input fields or not.
|
||||
|
||||
If enabled (default), hitting Tab causes focus navigation to the next widget.
|
||||
|
||||
If disabled, hitting Tab inserts a tab character into the text field.
|
||||
\returns 1 if Tab advances focus (default), 0 if Tab inserts tab characters.
|
||||
|
||||
\see tab_nav(int), Fl::OPTION_ARROW_FOCUS.
|
||||
*/
|
||||
int tab_nav() const {
|
||||
return tab_nav_;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,268 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// An input/chooser widget.
|
||||
// ______________ ____
|
||||
// | || __ |
|
||||
// | input area || \/ |
|
||||
// |______________||____|
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
// Copyright 2004 by Greg Ercolano.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Input_Choice widget . */
|
||||
|
||||
#ifndef Fl_Input_Choice_H
|
||||
#define Fl_Input_Choice_H
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Input.H>
|
||||
#include <FL/Fl_Menu_Button.H>
|
||||
#include <FL/fl_draw.H>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
A combination of the input widget and a menu button.
|
||||
|
||||
\image html input_choice.jpg
|
||||
\image latex input_choice.jpg "Fl_Input_Choice widget" width=6cm
|
||||
|
||||
The user can either type into the input area, or use the
|
||||
menu button chooser on the right to choose an item which loads
|
||||
the input area with the selected text.
|
||||
|
||||
The application can directly access both the internal Fl_Input
|
||||
and Fl_Menu_Button widgets respectively using the input() and menubutton()
|
||||
accessor methods.
|
||||
|
||||
The default behavior is to invoke the Fl_Input_Choice::callback()
|
||||
if the user changes the input field's contents, either by typing,
|
||||
pasting, or clicking a different item in the choice menu.
|
||||
|
||||
The callback can determine if an item was picked vs. typing
|
||||
into the input field by checking the value of menubutton()->changed(),
|
||||
which will be:
|
||||
|
||||
- 1: the user picked a different item in the choice menu
|
||||
- 0: the user typed or pasted directly into the input field
|
||||
|
||||
Example use:
|
||||
\code
|
||||
#include <stdio.h>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
#include <FL/Fl_Input_Choice.H>
|
||||
void choice_cb(Fl_Widget *w, void *userdata) {
|
||||
// Show info about the picked item
|
||||
Fl_Input_Choice *choice = (Fl_Input_Choice*)w;
|
||||
const Fl_Menu_Item *item = choice->menubutton()->mvalue();
|
||||
printf("*** Choice Callback:\n");
|
||||
printf(" item label()='%s'\n", item ? item->label() : "(No item)");
|
||||
printf(" item value()=%d\n", choice->menubutton()->value());
|
||||
printf(" input value()='%s'\n", choice->input()->value());
|
||||
printf(" The user %s\n", choice->menubutton()->changed()
|
||||
? "picked a menu item"
|
||||
: "typed text");
|
||||
}
|
||||
int main() {
|
||||
Fl_Double_Window win(200,100,"Input Choice");
|
||||
win.begin();
|
||||
Fl_Input_Choice choice(10,10,100,30);
|
||||
choice.callback(choice_cb, 0);
|
||||
choice.add("Red");
|
||||
choice.add("Orange");
|
||||
choice.add("Yellow");
|
||||
//choice.value("Red"); // uncomment to make "Red" default
|
||||
win.end();
|
||||
win.show();
|
||||
return Fl::run();
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
class FL_EXPORT Fl_Input_Choice : public Fl_Group {
|
||||
// Private class to handle slightly 'special' behavior of menu button
|
||||
class InputMenuButton : public Fl_Menu_Button {
|
||||
void draw() {
|
||||
draw_box(FL_UP_BOX, color());
|
||||
fl_color(active_r() ? labelcolor() : fl_inactive(labelcolor()));
|
||||
int xc = x()+w()/2, yc=y()+h()/2;
|
||||
fl_polygon(xc-5,yc-3,xc+5,yc-3,xc,yc+3);
|
||||
if (Fl::focus() == this) draw_focus();
|
||||
}
|
||||
public:
|
||||
InputMenuButton(int X,int Y,int W,int H,const char*L=0) :
|
||||
Fl_Menu_Button(X, Y, W, H, L) { box(FL_UP_BOX); }
|
||||
};
|
||||
|
||||
Fl_Input *inp_;
|
||||
InputMenuButton *menu_;
|
||||
|
||||
// note: this is used by the Fl_Input_Choice ctor defined in Fl_Group.
|
||||
static void menu_cb(Fl_Widget*, void *data) {
|
||||
Fl_Input_Choice *o=(Fl_Input_Choice *)data;
|
||||
Fl_Widget_Tracker wp(o);
|
||||
const Fl_Menu_Item *item = o->menubutton()->mvalue();
|
||||
if (item && item->flags & (FL_SUBMENU|FL_SUBMENU_POINTER)) return; // ignore submenus
|
||||
if (!strcmp(o->inp_->value(), o->menu_->text()))
|
||||
{
|
||||
o->Fl_Widget::clear_changed();
|
||||
if (o->when() & FL_WHEN_NOT_CHANGED)
|
||||
o->do_callback();
|
||||
}
|
||||
else
|
||||
{
|
||||
o->inp_->value(o->menu_->text());
|
||||
o->inp_->set_changed();
|
||||
o->Fl_Widget::set_changed();
|
||||
if (o->when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE))
|
||||
o->do_callback();
|
||||
}
|
||||
|
||||
if (wp.deleted()) return;
|
||||
|
||||
if (o->callback() != default_callback)
|
||||
{
|
||||
o->Fl_Widget::clear_changed();
|
||||
o->inp_->clear_changed();
|
||||
}
|
||||
}
|
||||
|
||||
// note: this is used by the Fl_Input_Choice ctor defined in Fl_Group.
|
||||
static void inp_cb(Fl_Widget*, void *data) {
|
||||
Fl_Input_Choice *o=(Fl_Input_Choice *)data;
|
||||
Fl_Widget_Tracker wp(o);
|
||||
if (o->inp_->changed()) {
|
||||
o->Fl_Widget::set_changed();
|
||||
if (o->when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE))
|
||||
o->do_callback();
|
||||
} else {
|
||||
o->Fl_Widget::clear_changed();
|
||||
if (o->when() & FL_WHEN_NOT_CHANGED)
|
||||
o->do_callback();
|
||||
}
|
||||
|
||||
if (wp.deleted()) return;
|
||||
|
||||
if (o->callback() != default_callback)
|
||||
o->Fl_Widget::clear_changed();
|
||||
}
|
||||
|
||||
// Custom resize behavior -- input stretches, menu button doesn't
|
||||
inline int inp_x() { return(x() + Fl::box_dx(box())); }
|
||||
inline int inp_y() { return(y() + Fl::box_dy(box())); }
|
||||
inline int inp_w() { return(w() - Fl::box_dw(box()) - 20); }
|
||||
inline int inp_h() { return(h() - Fl::box_dh(box())); }
|
||||
|
||||
inline int menu_x() { return(x() + w() - 20 - Fl::box_dx(box())); }
|
||||
inline int menu_y() { return(y() + Fl::box_dy(box())); }
|
||||
inline int menu_w() { return(20); }
|
||||
inline int menu_h() { return(h() - Fl::box_dh(box())); }
|
||||
|
||||
public:
|
||||
/**
|
||||
Creates a new Fl_Input_Choice widget using the given position, size,
|
||||
and label string.
|
||||
Inherited destructor destroys the widget and any values associated with it.
|
||||
*/
|
||||
Fl_Input_Choice(int X,int Y,int W,int H,const char*L=0);
|
||||
|
||||
/** Adds an item to the menu.
|
||||
You can access the more complex Fl_Menu_Button::add() methods
|
||||
(setting callbacks, userdata, etc), via menubutton(). Example:
|
||||
\code
|
||||
Fl_Input_Choice *choice = new Fl_Input_Choice(100,10,120,25,"Fonts");
|
||||
Fl_Menu_Button *mb = choice->menubutton(); // use Fl_Input_Choice's Fl_Menu_Button
|
||||
mb->add("Helvetica", 0, MyFont_CB, (void*)mydata); // use Fl_Menu_Button's add() methods
|
||||
mb->add("Courier", 0, MyFont_CB, (void*)mydata);
|
||||
mb->add("More..", 0, FontDialog_CB, (void*)mydata);
|
||||
\endcode
|
||||
*/
|
||||
void add(const char *s) { menu_->add(s); }
|
||||
/** Returns the combined changed() state of the input and menu button widget. */
|
||||
int changed() const { return inp_->changed() | Fl_Widget::changed(); }
|
||||
/** Clears the changed() state of both input and menu button widgets. */
|
||||
void clear_changed() {
|
||||
inp_->clear_changed();
|
||||
Fl_Widget::clear_changed();
|
||||
}
|
||||
/** Sets the changed() state of both input and menu button widgets
|
||||
to the specfied value.*/
|
||||
void set_changed() {
|
||||
inp_->set_changed();
|
||||
// no need to call Fl_Widget::set_changed()
|
||||
}
|
||||
/** Removes all items from the menu. */
|
||||
void clear() { menu_->clear(); }
|
||||
/** Gets the box type of the menu button */
|
||||
Fl_Boxtype down_box() const { return (menu_->down_box()); }
|
||||
/** Sets the box type of the menu button */
|
||||
void down_box(Fl_Boxtype b) { menu_->down_box(b); }
|
||||
/** Gets the Fl_Menu_Item array used for the menu. */
|
||||
const Fl_Menu_Item *menu() { return (menu_->menu()); }
|
||||
/** Sets the Fl_Menu_Item array used for the menu. */
|
||||
void menu(const Fl_Menu_Item *m) { menu_->menu(m); }
|
||||
void resize(int X, int Y, int W, int H) {
|
||||
Fl_Group::resize(X,Y,W,H);
|
||||
inp_->resize(inp_x(), inp_y(), inp_w(), inp_h());
|
||||
menu_->resize(menu_x(), menu_y(), menu_w(), menu_h());
|
||||
}
|
||||
/// Gets the Fl_Input text field's text color.
|
||||
Fl_Color textcolor() const { return (inp_->textcolor());}
|
||||
/// Sets the Fl_Input text field's text color to \p c.
|
||||
void textcolor(Fl_Color c) { inp_->textcolor(c);}
|
||||
/// Gets the Fl_Input text field's font style.
|
||||
Fl_Font textfont() const { return (inp_->textfont());}
|
||||
/// Sets the Fl_Input text field's font style to \p f.
|
||||
void textfont(Fl_Font f) { inp_->textfont(f);}
|
||||
/// Gets the Fl_Input text field's font size
|
||||
Fl_Fontsize textsize() const { return (inp_->textsize()); }
|
||||
/// Sets the Fl_Input text field's font size to \p s.
|
||||
void textsize(Fl_Fontsize s) { inp_->textsize(s); }
|
||||
/// Returns the Fl_Input text field's current contents.
|
||||
const char* value() const { return (inp_->value()); }
|
||||
/** Sets the Fl_Input text field's contents to \p val.
|
||||
Does not affect the menu selection.*/
|
||||
void value(const char *val) { inp_->value(val); }
|
||||
/** Chooses item# \p val in the menu, and sets the Fl_Input text field
|
||||
to that value. Any previous text is cleared.*/
|
||||
void value(int val) {
|
||||
menu_->value(val);
|
||||
inp_->value(menu_->text(val));
|
||||
}
|
||||
/** Returns a pointer to the internal Fl_Menu_Button widget.
|
||||
This can be used to access any of the methods of the menu button, e.g.
|
||||
\code
|
||||
Fl_Input_Choice *choice = new Fl_Input_Choice(100,10,120,25,"Choice:");
|
||||
[..]
|
||||
// Print all the items in the choice menu
|
||||
for ( int t=0; t<choice->menubutton()->size(); t++ ) {
|
||||
const Fl_Menu_Item &item = choice->menubutton()->menu()[t];
|
||||
printf("item %d -- label=%s\n", t, item.label() ? item.label() : "(Null)");
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
Fl_Menu_Button *menubutton() { return menu_; }
|
||||
/** Returns a pointer to the internal Fl_Input widget.
|
||||
This can be used to directly access all of the Fl_Input widget's
|
||||
methods.*/
|
||||
Fl_Input *input() { return inp_; }
|
||||
};
|
||||
|
||||
#endif // !Fl_Input_Choice_H
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,46 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Integer input header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Int_Input widget . */
|
||||
|
||||
#ifndef Fl_Int_Input_H
|
||||
#define Fl_Int_Input_H
|
||||
|
||||
#include "Fl_Input.H"
|
||||
|
||||
/**
|
||||
The Fl_Int_Input class is a subclass of Fl_Input that only allows
|
||||
the user to type decimal digits (or hex numbers of the form 0xaef).
|
||||
*/
|
||||
class FL_EXPORT Fl_Int_Input : public Fl_Input {
|
||||
public:
|
||||
/**
|
||||
Creates a new Fl_Int_Input widget using the given position,
|
||||
size, and label string. The default boxtype is FL_DOWN_BOX.
|
||||
|
||||
Inherited destructor destroys the widget and any value associated with it.
|
||||
*/
|
||||
Fl_Int_Input(int X,int Y,int W,int H,const char *l = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,44 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// JPEG image header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_JPEG_Image class . */
|
||||
|
||||
#ifndef Fl_JPEG_Image_H
|
||||
#define Fl_JPEG_Image_H
|
||||
# include "Fl_Image.H"
|
||||
|
||||
/**
|
||||
The Fl_JPEG_Image class supports loading, caching,
|
||||
and drawing of Joint Photographic Experts Group (JPEG) File
|
||||
Interchange Format (JFIF) images. The class supports grayscale
|
||||
and color (RGB) JPEG image files.
|
||||
*/
|
||||
class FL_EXPORT Fl_JPEG_Image : public Fl_RGB_Image {
|
||||
|
||||
public:
|
||||
|
||||
Fl_JPEG_Image(const char *filename);
|
||||
Fl_JPEG_Image(const char *name, const unsigned char *data);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,50 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Lighted button header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Light_Button widget . */
|
||||
|
||||
#ifndef Fl_Light_Button_H
|
||||
#define Fl_Light_Button_H
|
||||
|
||||
#include "Fl_Button.H"
|
||||
|
||||
/**
|
||||
This subclass displays the "on" state by turning on a light,
|
||||
rather than drawing pushed in. The shape of the "light"
|
||||
is initially set to FL_DOWN_BOX. The color of the light when
|
||||
on is controlled with selection_color(), which defaults to FL_YELLOW.
|
||||
|
||||
Buttons generate callbacks when they are clicked by the user. You
|
||||
control exactly when and how by changing the values for type() and when().
|
||||
<P ALIGN=CENTER>\image html Fl_Light_Button.png</P>
|
||||
\image latex Fl_Light_Button.png "Fl_Light_Button" width=4cm
|
||||
*/
|
||||
class FL_EXPORT Fl_Light_Button : public Fl_Button {
|
||||
protected:
|
||||
virtual void draw();
|
||||
public:
|
||||
virtual int handle(int);
|
||||
Fl_Light_Button(int x,int y,int w,int h,const char *l = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,36 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Line dial header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Line_Dial widget . */
|
||||
|
||||
#ifndef Fl_Line_Dial_H
|
||||
#define Fl_Line_Dial_H
|
||||
|
||||
#include "Fl_Dial.H"
|
||||
|
||||
class FL_EXPORT Fl_Line_Dial : public Fl_Dial {
|
||||
public:
|
||||
Fl_Line_Dial(int X,int Y,int W,int H, const char *L = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,24 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Old menu header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
// this include file is for back compatibility only
|
||||
#include "Fl_Menu_Item.H"
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,188 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Menu base class header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Menu_ widget . */
|
||||
|
||||
#ifndef Fl_Menu__H
|
||||
#define Fl_Menu__H
|
||||
|
||||
#ifndef Fl_Widget_H
|
||||
#include "Fl_Widget.H"
|
||||
#endif
|
||||
#include "Fl_Menu_Item.H"
|
||||
|
||||
/**
|
||||
Base class of all widgets that have a menu in FLTK.
|
||||
|
||||
Currently FLTK provides you with Fl_Menu_Button, Fl_Menu_Bar, and Fl_Choice.
|
||||
|
||||
The class contains a pointer to an array of structures of type Fl_Menu_Item.
|
||||
The array may either be supplied directly by the user program, or it may
|
||||
be "private": a dynamically allocated array managed by the Fl_Menu_.
|
||||
|
||||
When the user clicks a menu item, value() is set to that item
|
||||
and then:
|
||||
|
||||
- If the Fl_Menu_Item has a callback set, that callback
|
||||
is invoked with any userdata configured for it.
|
||||
(The Fl_Menu_ widget's callback is NOT invoked.)
|
||||
|
||||
- For any Fl_Menu_Items that \b don't have a callback set,
|
||||
the Fl_Menu_ widget's callback is invoked with any userdata
|
||||
configured for it. The callback can determine which item
|
||||
was picked using value(), mvalue(), item_pathname(), etc.
|
||||
*/
|
||||
class FL_EXPORT Fl_Menu_ : public Fl_Widget {
|
||||
|
||||
Fl_Menu_Item *menu_;
|
||||
const Fl_Menu_Item *value_;
|
||||
|
||||
protected:
|
||||
|
||||
uchar alloc; // flag indicates if menu_ is a dynamic copy (=1) or not (=0)
|
||||
uchar down_box_;
|
||||
Fl_Font textfont_;
|
||||
Fl_Fontsize textsize_;
|
||||
Fl_Color textcolor_;
|
||||
|
||||
int item_pathname_(char *name, int namelen, const Fl_Menu_Item *finditem,
|
||||
const Fl_Menu_Item *menu=0) const;
|
||||
public:
|
||||
Fl_Menu_(int,int,int,int,const char * =0);
|
||||
~Fl_Menu_();
|
||||
|
||||
int item_pathname(char *name, int namelen, const Fl_Menu_Item *finditem=0) const;
|
||||
const Fl_Menu_Item* picked(const Fl_Menu_Item*);
|
||||
const Fl_Menu_Item* find_item(const char *name);
|
||||
const Fl_Menu_Item* find_item(Fl_Callback*);
|
||||
int find_index(const char *name) const;
|
||||
int find_index(const Fl_Menu_Item *item) const;
|
||||
int find_index(Fl_Callback *cb) const;
|
||||
|
||||
/**
|
||||
Returns the menu item with the entered shortcut (key value).
|
||||
|
||||
This searches the complete menu() for a shortcut that matches the
|
||||
entered key value. It must be called for a FL_KEYBOARD or FL_SHORTCUT
|
||||
event.
|
||||
|
||||
If a match is found, the menu's callback will be called.
|
||||
|
||||
\return matched Fl_Menu_Item or NULL.
|
||||
*/
|
||||
const Fl_Menu_Item* test_shortcut() {return picked(menu()->test_shortcut());}
|
||||
void global();
|
||||
|
||||
/**
|
||||
Returns a pointer to the array of Fl_Menu_Items. This will either be
|
||||
the value passed to menu(value) or the private copy.
|
||||
\sa size() -- returns the size of the Fl_Menu_Item array.
|
||||
|
||||
\b Example: How to walk the array:
|
||||
\code
|
||||
for ( int t=0; t<menubar->size(); t++ ) { // walk array of items
|
||||
const Fl_Menu_Item &item = menubar->menu()[t]; // get each item
|
||||
fprintf(stderr, "item #%d -- label=%s, value=%s type=%s\n",
|
||||
t,
|
||||
item.label() ? item.label() : "(Null)", // menu terminators have NULL labels
|
||||
(item.flags & FL_MENU_VALUE) ? "set" : "clear", // value of toggle or radio items
|
||||
(item.flags & FL_SUBMENU) ? "Submenu" : "Item"); // see if item is a submenu or actual item
|
||||
}
|
||||
\endcode
|
||||
|
||||
*/
|
||||
const Fl_Menu_Item *menu() const {return menu_;}
|
||||
void menu(const Fl_Menu_Item *m);
|
||||
void copy(const Fl_Menu_Item *m, void* user_data = 0);
|
||||
int insert(int index, const char*, int shortcut, Fl_Callback*, void* = 0, int = 0);
|
||||
int add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0); // see src/Fl_Menu_add.cxx
|
||||
/** See int Fl_Menu_::add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0) */
|
||||
int add(const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) {
|
||||
return add(a,fl_old_shortcut(b),c,d,e);
|
||||
}
|
||||
/** See int Fl_Menu_::insert(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0) */
|
||||
int insert(int index, const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) {
|
||||
return insert(index,a,fl_old_shortcut(b),c,d,e);
|
||||
}
|
||||
int add(const char *);
|
||||
int size() const ;
|
||||
void size(int W, int H) { Fl_Widget::size(W, H); }
|
||||
void clear();
|
||||
int clear_submenu(int index);
|
||||
void replace(int,const char *);
|
||||
void remove(int);
|
||||
/** Changes the shortcut of item \p i to \p s. */
|
||||
void shortcut(int i, int s) {menu_[i].shortcut(s);}
|
||||
/** Sets the flags of item i. For a list of the flags, see Fl_Menu_Item. */
|
||||
void mode(int i,int fl) {menu_[i].flags = fl;}
|
||||
/** Gets the flags of item i. For a list of the flags, see Fl_Menu_Item. */
|
||||
int mode(int i) const {return menu_[i].flags;}
|
||||
|
||||
/** Returns a pointer to the last menu item that was picked. */
|
||||
const Fl_Menu_Item *mvalue() const {return value_;}
|
||||
/** Returns the index into menu() of the last item chosen by the user. It is zero initially. */
|
||||
int value() const {return value_ ? (int)(value_-menu_) : -1;}
|
||||
int value(const Fl_Menu_Item*);
|
||||
/**
|
||||
The value is the index into menu() of the last item chosen by
|
||||
the user. It is zero initially. You can set it as an integer, or set
|
||||
it with a pointer to a menu item. The set routines return non-zero if
|
||||
the new value is different than the old one.
|
||||
*/
|
||||
int value(int i) {return value(menu_+i);}
|
||||
/** Returns the title of the last item chosen. */
|
||||
const char *text() const {return value_ ? value_->text : 0;}
|
||||
/** Returns the title of item i. */
|
||||
const char *text(int i) const {return menu_[i].text;}
|
||||
|
||||
/** Gets the current font of menu item labels. */
|
||||
Fl_Font textfont() const {return textfont_;}
|
||||
/** Sets the current font of menu item labels. */
|
||||
void textfont(Fl_Font c) {textfont_=c;}
|
||||
/** Gets the font size of menu item labels. */
|
||||
Fl_Fontsize textsize() const {return textsize_;}
|
||||
/** Sets the font size of menu item labels. */
|
||||
void textsize(Fl_Fontsize c) {textsize_=c;}
|
||||
/** Get the current color of menu item labels. */
|
||||
Fl_Color textcolor() const {return textcolor_;}
|
||||
/** Sets the current color of menu item labels. */
|
||||
void textcolor(Fl_Color c) {textcolor_=c;}
|
||||
|
||||
/**
|
||||
This box type is used to surround the currently-selected items in the
|
||||
menus. If this is FL_NO_BOX then it acts like
|
||||
FL_THIN_UP_BOX and selection_color() acts like
|
||||
FL_WHITE, for back compatibility.
|
||||
*/
|
||||
Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
|
||||
/** See Fl_Boxtype Fl_Menu_::down_box() const */
|
||||
void down_box(Fl_Boxtype b) {down_box_ = b;}
|
||||
|
||||
/** For back compatibility, same as selection_color() */
|
||||
Fl_Color down_color() const {return selection_color();}
|
||||
/** For back compatibility, same as selection_color() */
|
||||
void down_color(unsigned c) {selection_color(c);}
|
||||
void setonly(Fl_Menu_Item* item);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,97 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Menu bar header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Menu_Bar widget . */
|
||||
|
||||
#ifndef Fl_Menu_Bar_H
|
||||
#define Fl_Menu_Bar_H
|
||||
|
||||
#include "Fl_Menu_.H"
|
||||
|
||||
/**
|
||||
This widget provides a standard menubar interface. Usually you will
|
||||
put this widget along the top edge of your window. The height of the
|
||||
widget should be 30 for the menu titles to draw correctly with the
|
||||
default font.
|
||||
|
||||
The items on the bar and the menus they bring up are defined by a
|
||||
single Fl_Menu_Item array.
|
||||
Because a Fl_Menu_Item array defines a hierarchy, the
|
||||
top level menu defines the items in the menubar, while the submenus
|
||||
define the pull-down menus. Sub-sub menus and lower pop up to the right
|
||||
of the submenus.
|
||||
|
||||
\image html menubar.png
|
||||
\image latex menubar.png " menubar" width=12cm
|
||||
|
||||
If there is an item in the top menu that is not a title of a
|
||||
submenu, then it acts like a "button" in the menubar. Clicking on it
|
||||
will pick it.
|
||||
|
||||
When the user clicks a menu item, value() is set to that item
|
||||
and then:
|
||||
|
||||
- The item's callback is done if one has been set; the
|
||||
Fl_Menu_Bar is passed as the Fl_Widget* argument,
|
||||
along with any userdata configured for the callback.
|
||||
|
||||
- If the item does not have a callback, the Fl_Menu_Bar's callback
|
||||
is done instead, along with any userdata configured for the callback.
|
||||
The callback can determine which item was picked using
|
||||
value(), mvalue(), item_pathname(), etc.
|
||||
|
||||
Submenus will also pop up in response to shortcuts indicated by
|
||||
putting a '&' character in the name field of the menu item. If you put a
|
||||
'&' character in a top-level "button" then the shortcut picks it. The
|
||||
'&' character in submenus is ignored until the menu is popped up.
|
||||
|
||||
Typing the shortcut() of any of the menu items will cause
|
||||
callbacks exactly the same as when you pick the item with the mouse.
|
||||
*/
|
||||
class FL_EXPORT Fl_Menu_Bar : public Fl_Menu_ {
|
||||
protected:
|
||||
void draw();
|
||||
public:
|
||||
int handle(int);
|
||||
/**
|
||||
Creates a new Fl_Menu_Bar widget using the given position,
|
||||
size, and label string. The default boxtype is FL_UP_BOX.
|
||||
|
||||
The constructor sets menu() to NULL. See
|
||||
Fl_Menu_ for the methods to set or change the menu.
|
||||
|
||||
labelsize(), labelfont(), and labelcolor()
|
||||
are used to control how the menubar items are drawn. They are
|
||||
initialized from the Fl_Menu static variables, but you can
|
||||
change them if desired.
|
||||
|
||||
label() is ignored unless you change align() to
|
||||
put it outside the menubar.
|
||||
|
||||
The destructor removes the Fl_Menu_Bar widget and all of its
|
||||
menu items.
|
||||
*/
|
||||
Fl_Menu_Bar(int X, int Y, int W, int H, const char *l=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,85 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Menu button header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Menu_Button widget . */
|
||||
|
||||
#ifndef Fl_Menu_Button_H
|
||||
#define Fl_Menu_Button_H
|
||||
|
||||
#include "Fl_Menu_.H"
|
||||
|
||||
/**
|
||||
This is a button that when pushed pops up a menu (or hierarchy of
|
||||
menus) defined by an array of
|
||||
Fl_Menu_Item objects.
|
||||
<P ALIGN=CENTER>\image html menu_button.png</P>
|
||||
\image latex menu_button.png " menu_button" width=5cm
|
||||
<P>Normally any mouse button will pop up a menu and it is lined up
|
||||
below the button as shown in the picture. However an Fl_Menu_Button
|
||||
may also control a pop-up menu. This is done by setting the type().
|
||||
If type() is zero a normal menu button is produced.
|
||||
If it is nonzero then this is a pop-up menu. The bits in type() indicate
|
||||
what mouse buttons pop up the menu (see Fl_Menu_Button::popup_buttons). </P>
|
||||
<P>The menu will also pop up in response to shortcuts indicated by
|
||||
putting a '&' character in the label(). </P>
|
||||
<P>Typing the shortcut() of any of the menu items will cause
|
||||
callbacks exactly the same as when you pick the item with the mouse.
|
||||
The '&' character in menu item names are only looked at when the menu is
|
||||
popped up, however. </P>
|
||||
|
||||
When the user clicks a menu item, value() is set to that item
|
||||
and then:
|
||||
|
||||
- The item's callback is done if one has been set; the
|
||||
Fl_Menu_Button is passed as the Fl_Widget* argument,
|
||||
along with any userdata configured for the callback.
|
||||
|
||||
- If the item does not have a callback, the Fl_Menu_Button's callback
|
||||
is done instead, along with any userdata configured for it.
|
||||
The callback can determine which item was picked using
|
||||
value(), mvalue(), item_pathname(), etc.
|
||||
*/
|
||||
class FL_EXPORT Fl_Menu_Button : public Fl_Menu_ {
|
||||
protected:
|
||||
void draw();
|
||||
public:
|
||||
/**
|
||||
\brief indicate what mouse buttons pop up the menu.
|
||||
|
||||
Values for type() used to indicate what mouse buttons pop up the menu.
|
||||
Fl_Menu_Button::POPUP3 is usually what you want.
|
||||
*/
|
||||
enum popup_buttons {POPUP1 = 1, /**< pops up with the mouse 1st button. */
|
||||
POPUP2, /**< pops up with the mouse 2nd button. */
|
||||
POPUP12, /**< pops up with the mouse 1st or 2nd buttons. */
|
||||
POPUP3, /**< pops up with the mouse 3rd button. */
|
||||
POPUP13, /**< pops up with the mouse 1st or 3rd buttons. */
|
||||
POPUP23, /**< pops up with the mouse 2nd or 3rd buttons. */
|
||||
POPUP123 /**< pops up with any mouse button. */
|
||||
};
|
||||
int handle(int);
|
||||
const Fl_Menu_Item* popup();
|
||||
Fl_Menu_Button(int,int,int,int,const char * =0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,443 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Menu item header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
#ifndef Fl_Menu_Item_H
|
||||
#define Fl_Menu_Item_H
|
||||
|
||||
# include "Fl_Widget.H"
|
||||
# include "Fl_Image.H"
|
||||
|
||||
# if defined(__APPLE__) && defined(check)
|
||||
# undef check
|
||||
# endif
|
||||
|
||||
// doxygen needs the following line to enable e.g. ::FL_MENU_TOGGLE to link to the enums
|
||||
/// @file
|
||||
|
||||
enum { // values for flags:
|
||||
FL_MENU_INACTIVE = 1, ///< Deactivate menu item (gray out)
|
||||
FL_MENU_TOGGLE= 2, ///< Item is a checkbox toggle (shows checkbox for on/off state)
|
||||
FL_MENU_VALUE = 4, ///< The on/off state for checkbox/radio buttons (if set, state is 'on')
|
||||
FL_MENU_RADIO = 8, ///< Item is a radio button (one checkbox of many can be on)
|
||||
FL_MENU_INVISIBLE = 0x10, ///< Item will not show up (shortcut will work)
|
||||
FL_SUBMENU_POINTER = 0x20, ///< Indicates user_data() is a pointer to another menu array
|
||||
FL_SUBMENU = 0x40, ///< This item is a submenu to other items
|
||||
FL_MENU_DIVIDER = 0x80, ///< Creates divider line below this item. Also ends a group of radio buttons.
|
||||
FL_MENU_HORIZONTAL = 0x100 ///< ??? -- reserved
|
||||
};
|
||||
|
||||
extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
|
||||
|
||||
class Fl_Menu_;
|
||||
|
||||
/**
|
||||
The Fl_Menu_Item structure defines a single menu item that
|
||||
is used by the Fl_Menu_ class.
|
||||
\code
|
||||
struct Fl_Menu_Item {
|
||||
const char* text; // label()
|
||||
ulong shortcut_;
|
||||
Fl_Callback* callback_;
|
||||
void* user_data_;
|
||||
int flags;
|
||||
uchar labeltype_;
|
||||
uchar labelfont_;
|
||||
uchar labelsize_;
|
||||
uchar labelcolor_;
|
||||
};
|
||||
|
||||
enum { // values for flags:
|
||||
FL_MENU_INACTIVE = 1, // Deactivate menu item (gray out)
|
||||
FL_MENU_TOGGLE = 2, // Item is a checkbox toggle (shows checkbox for on/off state)
|
||||
FL_MENU_VALUE = 4, // The on/off state for checkbox/radio buttons (if set, state is 'on')
|
||||
FL_MENU_RADIO = 8, // Item is a radio button (one checkbox of many can be on)
|
||||
FL_MENU_INVISIBLE = 0x10, // Item will not show up (shortcut will work)
|
||||
FL_SUBMENU_POINTER = 0x20, // Indicates user_data() is a pointer to another menu array
|
||||
FL_SUBMENU = 0x40, // This item is a submenu to other items
|
||||
FL_MENU_DIVIDER = 0x80, // Creates divider line below this item. Also ends a group of radio buttons.
|
||||
FL_MENU_HORIZONTAL = 0x100 // ??? -- reserved
|
||||
};
|
||||
\endcode
|
||||
Typically menu items are statically defined; for example:
|
||||
\code
|
||||
Fl_Menu_Item popup[] = {
|
||||
{"&alpha", FL_ALT+'a', the_cb, (void*)1},
|
||||
{"&beta", FL_ALT+'b', the_cb, (void*)2},
|
||||
{"gamma", FL_ALT+'c', the_cb, (void*)3, FL_MENU_DIVIDER},
|
||||
{"&strange", 0, strange_cb},
|
||||
{"&charm", 0, charm_cb},
|
||||
{"&truth", 0, truth_cb},
|
||||
{"b&eauty", 0, beauty_cb},
|
||||
{"sub&menu", 0, 0, 0, FL_SUBMENU},
|
||||
{"one"},
|
||||
{"two"},
|
||||
{"three"},
|
||||
{0},
|
||||
{"inactive", FL_ALT+'i', 0, 0, FL_MENU_INACTIVE|FL_MENU_DIVIDER},
|
||||
{"invisible",FL_ALT+'i', 0, 0, FL_MENU_INVISIBLE},
|
||||
{"check", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE|FL_MENU_VALUE},
|
||||
{"box", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE},
|
||||
{0}};
|
||||
\endcode
|
||||
produces:
|
||||
|
||||
\image html menu.png
|
||||
\image latex menu.png "menu" width=10cm
|
||||
|
||||
A submenu title is identified by the bit FL_SUBMENU in the
|
||||
flags field, and ends with a label() that is NULL.
|
||||
You can nest menus to any depth. A pointer to the first item in the
|
||||
submenu can be treated as an Fl_Menu array itself. It is also
|
||||
possible to make separate submenu arrays with FL_SUBMENU_POINTER flags.
|
||||
|
||||
You should use the method functions to access structure members and
|
||||
not access them directly to avoid compatibility problems with future
|
||||
releases of FLTK.
|
||||
*/
|
||||
struct FL_EXPORT Fl_Menu_Item {
|
||||
const char *text; ///< menu item text, returned by label()
|
||||
int shortcut_; ///< menu item shortcut
|
||||
Fl_Callback *callback_; ///< menu item callback
|
||||
void *user_data_; ///< menu item user_data for the menu's callback
|
||||
int flags; ///< menu item flags like FL_MENU_TOGGLE, FL_MENU_RADIO
|
||||
uchar labeltype_; ///< how the menu item text looks like
|
||||
Fl_Font labelfont_; ///< which font for this menu item text
|
||||
Fl_Fontsize labelsize_; ///< size of menu item text
|
||||
Fl_Color labelcolor_; ///< menu item text color
|
||||
|
||||
// advance N items, skipping submenus:
|
||||
const Fl_Menu_Item *next(int=1) const;
|
||||
|
||||
/**
|
||||
Advances a pointer by n items through a menu array, skipping
|
||||
the contents of submenus and invisible items. There are two calls so
|
||||
that you can advance through const and non-const data.
|
||||
*/
|
||||
Fl_Menu_Item *next(int i=1) {
|
||||
return (Fl_Menu_Item*)(((const Fl_Menu_Item*)this)->next(i));}
|
||||
|
||||
/** Returns the first menu item, same as next(0). */
|
||||
const Fl_Menu_Item *first() const { return next(0); }
|
||||
|
||||
/** Returns the first menu item, same as next(0). */
|
||||
Fl_Menu_Item *first() { return next(0); }
|
||||
|
||||
// methods on menu items:
|
||||
/**
|
||||
Returns the title of the item.
|
||||
A NULL here indicates the end of the menu (or of a submenu).
|
||||
A '&' in the item will print an underscore under the next letter,
|
||||
and if the menu is popped up that letter will be a "shortcut" to pick
|
||||
that item. To get a real '&' put two in a row.
|
||||
*/
|
||||
const char* label() const {return text;}
|
||||
|
||||
/** See const char* Fl_Menu_Item::label() const */
|
||||
void label(const char* a) {text=a;}
|
||||
|
||||
/** See const char* Fl_Menu_Item::label() const */
|
||||
void label(Fl_Labeltype a,const char* b) {labeltype_ = a; text = b;}
|
||||
|
||||
/**
|
||||
Returns the menu item's labeltype.
|
||||
A labeltype identifies a routine that draws the label of the
|
||||
widget. This can be used for special effects such as emboss, or to use
|
||||
the label() pointer as another form of data such as a bitmap.
|
||||
The value FL_NORMAL_LABEL prints the label as text.
|
||||
*/
|
||||
Fl_Labeltype labeltype() const {return (Fl_Labeltype)labeltype_;}
|
||||
|
||||
/**
|
||||
Sets the menu item's labeltype.
|
||||
A labeltype identifies a routine that draws the label of the
|
||||
widget. This can be used for special effects such as emboss, or to use
|
||||
the label() pointer as another form of data such as a bitmap.
|
||||
The value FL_NORMAL_LABEL prints the label as text.
|
||||
*/
|
||||
void labeltype(Fl_Labeltype a) {labeltype_ = a;}
|
||||
|
||||
/**
|
||||
Gets the menu item's label color.
|
||||
This color is passed to the labeltype routine, and is typically the
|
||||
color of the label text. This defaults to FL_BLACK. If this
|
||||
color is not black fltk will \b not use overlay bitplanes to draw
|
||||
the menu - this is so that images put in the menu draw correctly.
|
||||
*/
|
||||
Fl_Color labelcolor() const {return labelcolor_;}
|
||||
|
||||
/**
|
||||
Sets the menu item's label color.
|
||||
\see Fl_Color Fl_Menu_Item::labelcolor() const
|
||||
*/
|
||||
void labelcolor(Fl_Color a) {labelcolor_ = a;}
|
||||
/**
|
||||
Gets the menu item's label font.
|
||||
Fonts are identified by small 8-bit indexes into a table. See the
|
||||
enumeration list for predefined fonts. The default value is a
|
||||
Helvetica font. The function Fl::set_font() can define new fonts.
|
||||
*/
|
||||
Fl_Font labelfont() const {return labelfont_;}
|
||||
|
||||
/**
|
||||
Sets the menu item's label font.
|
||||
Fonts are identified by small 8-bit indexes into a table. See the
|
||||
enumeration list for predefined fonts. The default value is a
|
||||
Helvetica font. The function Fl::set_font() can define new fonts.
|
||||
*/
|
||||
void labelfont(Fl_Font a) {labelfont_ = a;}
|
||||
|
||||
/** Gets the label font pixel size/height. */
|
||||
Fl_Fontsize labelsize() const {return labelsize_;}
|
||||
|
||||
/** Sets the label font pixel size/height.*/
|
||||
void labelsize(Fl_Fontsize a) {labelsize_ = a;}
|
||||
|
||||
/**
|
||||
Returns the callback function that is set for the menu item.
|
||||
Each item has space for a callback function and an argument for that
|
||||
function. Due to back compatibility, the Fl_Menu_Item itself
|
||||
is not passed to the callback, instead you have to get it by calling
|
||||
((Fl_Menu_*)w)->mvalue() where w is the widget argument.
|
||||
*/
|
||||
Fl_Callback_p callback() const {return callback_;}
|
||||
|
||||
/**
|
||||
Sets the menu item's callback function and userdata() argument.
|
||||
\see Fl_Callback_p Fl_MenuItem::callback() const
|
||||
*/
|
||||
void callback(Fl_Callback* c, void* p) {callback_=c; user_data_=p;}
|
||||
|
||||
/**
|
||||
Sets the menu item's callback function.
|
||||
This method does not set the userdata() argument.
|
||||
\see Fl_Callback_p Fl_MenuItem::callback() const
|
||||
*/
|
||||
void callback(Fl_Callback* c) {callback_=c;}
|
||||
|
||||
/**
|
||||
Sets the menu item's callback function.
|
||||
This method does not set the userdata() argument.
|
||||
\see Fl_Callback_p Fl_MenuItem::callback() const
|
||||
*/
|
||||
void callback(Fl_Callback0*c) {callback_=(Fl_Callback*)c;}
|
||||
|
||||
/**
|
||||
Sets the menu item's callback function and userdata() argument.
|
||||
This method does not set the userdata() argument.
|
||||
The argument \p is cast to void* and stored as the userdata()
|
||||
for the menu item's callback function.
|
||||
\see Fl_Callback_p Fl_MenuItem::callback() const
|
||||
*/
|
||||
void callback(Fl_Callback1*c, long p=0) {callback_=(Fl_Callback*)c; user_data_=(void*)(fl_intptr_t)p;}
|
||||
|
||||
/**
|
||||
Gets the user_data() argument that is sent to the callback function.
|
||||
*/
|
||||
void* user_data() const {return user_data_;}
|
||||
/**
|
||||
Sets the user_data() argument that is sent to the callback function.
|
||||
*/
|
||||
void user_data(void* v) {user_data_ = v;}
|
||||
/**
|
||||
Gets the user_data() argument that is sent to the callback function.
|
||||
For convenience you can also define the callback as taking a long
|
||||
argument. This method casts the stored userdata() argument to long
|
||||
and returns it as a \e long value.
|
||||
*/
|
||||
long argument() const {return (long)(fl_intptr_t)user_data_;}
|
||||
/**
|
||||
Sets the user_data() argument that is sent to the callback function.
|
||||
For convenience you can also define the callback as taking a long
|
||||
argument. This method casts the given argument \p v to void*
|
||||
and stores it in the menu item's userdata() member.
|
||||
This may not be portable to some machines.
|
||||
*/
|
||||
void argument(long v) {user_data_ = (void*)(fl_intptr_t)v;}
|
||||
|
||||
/** Gets what key combination shortcut will trigger the menu item. */
|
||||
int shortcut() const {return shortcut_;}
|
||||
|
||||
/**
|
||||
Sets exactly what key combination will trigger the menu item. The
|
||||
value is a logical 'or' of a key and a set of shift flags, for instance
|
||||
FL_ALT+'a' or FL_ALT+FL_F+10 or just 'a'. A value of
|
||||
zero disables the shortcut.
|
||||
|
||||
The key can be any value returned by Fl::event_key(), but will usually
|
||||
be an ASCII letter. Use a lower-case letter unless you require the shift
|
||||
key to be held down.
|
||||
|
||||
The shift flags can be any set of values accepted by Fl::event_state().
|
||||
If the bit is on that shift key must be pushed. Meta, Alt, Ctrl,
|
||||
and Shift must be off if they are not in the shift flags (zero for the
|
||||
other bits indicates a "don't care" setting).
|
||||
*/
|
||||
void shortcut(int s) {shortcut_ = s;}
|
||||
/**
|
||||
Returns true if either FL_SUBMENU or FL_SUBMENU_POINTER
|
||||
is on in the flags. FL_SUBMENU indicates an embedded submenu
|
||||
that goes from the next item through the next one with a NULL
|
||||
label(). FL_SUBMENU_POINTER indicates that user_data()
|
||||
is a pointer to another menu array.
|
||||
*/
|
||||
int submenu() const {return flags&(FL_SUBMENU|FL_SUBMENU_POINTER);}
|
||||
/**
|
||||
Returns true if a checkbox will be drawn next to this item.
|
||||
This is true if FL_MENU_TOGGLE or FL_MENU_RADIO is set in the flags.
|
||||
*/
|
||||
int checkbox() const {return flags&FL_MENU_TOGGLE;}
|
||||
/**
|
||||
Returns true if this item is a radio item.
|
||||
When a radio button is selected all "adjacent" radio buttons are
|
||||
turned off. A set of radio items is delimited by an item that has
|
||||
radio() false, or by an item with FL_MENU_DIVIDER turned on.
|
||||
*/
|
||||
int radio() const {return flags&FL_MENU_RADIO;}
|
||||
/** Returns the current value of the check or radio item.
|
||||
This is zero (0) if the menu item is not checked and
|
||||
non-zero otherwise. You should not rely on a particular value,
|
||||
only zero or non-zero.
|
||||
\note The returned value for a checked menu item as of FLTK 1.3.2
|
||||
is FL_MENU_VALUE (4), but may be 1 in a future version.
|
||||
*/
|
||||
int value() const {return flags&FL_MENU_VALUE;}
|
||||
/**
|
||||
Turns the check or radio item "on" for the menu item. Note that this
|
||||
does not turn off any adjacent radio items like set_only() does.
|
||||
*/
|
||||
void set() {flags |= FL_MENU_VALUE;}
|
||||
|
||||
/** Turns the check or radio item "off" for the menu item. */
|
||||
void clear() {flags &= ~FL_MENU_VALUE;}
|
||||
|
||||
void setonly();
|
||||
|
||||
/** Gets the visibility of an item. */
|
||||
int visible() const {return !(flags&FL_MENU_INVISIBLE);}
|
||||
|
||||
/** Makes an item visible in the menu. */
|
||||
void show() {flags &= ~FL_MENU_INVISIBLE;}
|
||||
|
||||
/** Hides an item in the menu. */
|
||||
void hide() {flags |= FL_MENU_INVISIBLE;}
|
||||
|
||||
/** Gets whether or not the item can be picked. */
|
||||
int active() const {return !(flags&FL_MENU_INACTIVE);}
|
||||
|
||||
/** Allows a menu item to be picked. */
|
||||
void activate() {flags &= ~FL_MENU_INACTIVE;}
|
||||
/**
|
||||
Prevents a menu item from being picked. Note that this will also cause
|
||||
the menu item to appear grayed-out.
|
||||
*/
|
||||
void deactivate() {flags |= FL_MENU_INACTIVE;}
|
||||
/** Returns non 0 if FL_INACTIVE and FL_INVISIBLE are cleared, 0 otherwise. */
|
||||
int activevisible() const {return !(flags & (FL_MENU_INACTIVE|FL_MENU_INVISIBLE));}
|
||||
|
||||
// compatibility for FLUID so it can set the image of a menu item...
|
||||
|
||||
/** compatibility api for FLUID, same as a->label(this) */
|
||||
void image(Fl_Image* a) {a->label(this);}
|
||||
|
||||
/** compatibility api for FLUID, same as a.label(this) */
|
||||
void image(Fl_Image& a) {a.label(this);}
|
||||
|
||||
// used by menubar:
|
||||
int measure(int* h, const Fl_Menu_*) const;
|
||||
void draw(int x, int y, int w, int h, const Fl_Menu_*, int t=0) const;
|
||||
|
||||
// popup menus without using an Fl_Menu_ widget:
|
||||
const Fl_Menu_Item* popup(
|
||||
int X, int Y,
|
||||
const char *title = 0,
|
||||
const Fl_Menu_Item* picked=0,
|
||||
const Fl_Menu_* = 0) const;
|
||||
const Fl_Menu_Item* pulldown(
|
||||
int X, int Y, int W, int H,
|
||||
const Fl_Menu_Item* picked = 0,
|
||||
const Fl_Menu_* = 0,
|
||||
const Fl_Menu_Item* title = 0,
|
||||
int menubar=0) const;
|
||||
const Fl_Menu_Item* test_shortcut() const;
|
||||
const Fl_Menu_Item* find_shortcut(int *ip=0, const bool require_alt = false) const;
|
||||
|
||||
/**
|
||||
Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument.
|
||||
The callback is called with the stored user_data() as its second argument.
|
||||
You must first check that callback() is non-zero before calling this.
|
||||
*/
|
||||
void do_callback(Fl_Widget* o) const {callback_(o, user_data_);}
|
||||
|
||||
/**
|
||||
Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument.
|
||||
This call overrides the callback's second argument with the given value \p arg.
|
||||
You must first check that callback() is non-zero before calling this.
|
||||
*/
|
||||
void do_callback(Fl_Widget* o,void* arg) const {callback_(o, arg);}
|
||||
|
||||
/**
|
||||
Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument.
|
||||
This call overrides the callback's second argument with the
|
||||
given value \p arg. long \p arg is cast to void* when calling
|
||||
the callback.
|
||||
You must first check that callback() is non-zero before calling this.
|
||||
*/
|
||||
void do_callback(Fl_Widget* o,long arg) const {callback_(o, (void*)(fl_intptr_t)arg);}
|
||||
|
||||
// back-compatibility, do not use:
|
||||
|
||||
/** back compatibility only \deprecated. */
|
||||
int checked() const {return flags&FL_MENU_VALUE;}
|
||||
|
||||
/** back compatibility only \deprecated. */
|
||||
void check() {flags |= FL_MENU_VALUE;}
|
||||
|
||||
/** back compatibility only \deprecated. */
|
||||
void uncheck() {flags &= ~FL_MENU_VALUE;}
|
||||
|
||||
int insert(int,const char*,int,Fl_Callback*,void* =0, int =0);
|
||||
int add(const char*, int shortcut, Fl_Callback*, void* =0, int = 0);
|
||||
|
||||
/** See int add(const char*, int shortcut, Fl_Callback*, void*, int) */
|
||||
int add(const char*a, const char* b, Fl_Callback* c,
|
||||
void* d = 0, int e = 0) {
|
||||
return add(a,fl_old_shortcut(b),c,d,e);}
|
||||
|
||||
int size() const ;
|
||||
};
|
||||
|
||||
typedef Fl_Menu_Item Fl_Menu; // back compatibility
|
||||
|
||||
enum { // back-compatibility enum:
|
||||
FL_PUP_NONE = 0,
|
||||
FL_PUP_GREY = FL_MENU_INACTIVE,
|
||||
FL_PUP_GRAY = FL_MENU_INACTIVE,
|
||||
FL_MENU_BOX = FL_MENU_TOGGLE,
|
||||
FL_PUP_BOX = FL_MENU_TOGGLE,
|
||||
FL_MENU_CHECK = FL_MENU_VALUE,
|
||||
FL_PUP_CHECK = FL_MENU_VALUE,
|
||||
FL_PUP_RADIO = FL_MENU_RADIO,
|
||||
FL_PUP_INVISIBLE = FL_MENU_INVISIBLE,
|
||||
FL_PUP_SUBMENU = FL_SUBMENU_POINTER
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,57 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Menu window header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Menu_Window widget . */
|
||||
|
||||
#ifndef Fl_Menu_Window_H
|
||||
#define Fl_Menu_Window_H
|
||||
|
||||
#include "Fl_Single_Window.H"
|
||||
|
||||
/**
|
||||
The Fl_Menu_Window widget is a window type used for menus. By
|
||||
default the window is drawn in the hardware overlay planes if they are
|
||||
available so that the menu don't force the rest of the window to
|
||||
redraw.
|
||||
*/
|
||||
class FL_EXPORT Fl_Menu_Window : public Fl_Single_Window {
|
||||
public:
|
||||
void show();
|
||||
void erase();
|
||||
void flush();
|
||||
void hide();
|
||||
/** Tells if hardware overlay mode is set */
|
||||
unsigned int overlay() {return !(flags()&NO_OVERLAY);}
|
||||
/** Tells FLTK to use hardware overlay planes if they are available. */
|
||||
void set_overlay() {clear_flag(NO_OVERLAY);}
|
||||
/** Tells FLTK to use normal drawing planes instead of overlay planes.
|
||||
This is usually necessary if your menu contains multi-color pixmaps. */
|
||||
void clear_overlay() {set_flag(NO_OVERLAY);}
|
||||
~Fl_Menu_Window();
|
||||
/** Creates a new Fl_Menu_Window widget using the given size, and label string. */
|
||||
Fl_Menu_Window(int W, int H, const char *l = 0);
|
||||
/** Creates a new Fl_Menu_Window widget using the given position, size, and label string. */
|
||||
Fl_Menu_Window(int X, int Y, int W, int H, const char *l = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,54 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Multi browser header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Multi_Browser widget . */
|
||||
|
||||
#ifndef Fl_Multi_Browser_H
|
||||
#define Fl_Multi_Browser_H
|
||||
|
||||
#include "Fl_Browser.H"
|
||||
|
||||
/**
|
||||
The Fl_Multi_Browser class is a subclass of Fl_Browser
|
||||
which lets the user select any set of the lines. The user interface
|
||||
is Macintosh style: clicking an item turns off all the others and
|
||||
selects that one, dragging selects all the items the mouse moves over,
|
||||
and ctrl + click (Cmd+click on the Mac OS platform) toggles the items.
|
||||
Shift + click extends the selection until the clicked item.
|
||||
This is different from how forms did it.
|
||||
Normally the callback is done when the user releases the
|
||||
mouse, but you can change this with when().
|
||||
<P>See Fl_Browser for methods to add and remove lines from the browser.
|
||||
*/
|
||||
class FL_EXPORT Fl_Multi_Browser : public Fl_Browser {
|
||||
public:
|
||||
/**
|
||||
Creates a new Fl_Multi_Browser widget using the given
|
||||
position, size, and label string. The default boxtype is FL_DOWN_BOX.
|
||||
The constructor specializes Fl_Browser() by setting the type to FL_MULTI_BROWSER.
|
||||
The destructor destroys the widget and frees all memory that has been allocated.
|
||||
*/
|
||||
Fl_Multi_Browser(int X,int Y,int W,int H,const char *L=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,78 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Multi-label header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2015 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
#ifndef Fl_Multi_Label_H
|
||||
#define Fl_Multi_Label_H
|
||||
|
||||
class Fl_Widget;
|
||||
struct Fl_Menu_Item;
|
||||
|
||||
/** This struct allows multiple labels to be added to objects that might normally have only one label.
|
||||
|
||||
This struct allows a mixed text and/or graphics label to be applied to an object that
|
||||
would normally only have a single (usually text only) label.
|
||||
|
||||
Most regular FLTK widgets now support the ability to associate both images and text
|
||||
with a label but some special cases, notably the non-widget Fl_Menu_Item objects, do not.
|
||||
Fl_Multi_Label may be used to create menu items that have an icon and text, which would
|
||||
not normally be possible for an Fl_Menu_Item.
|
||||
For example, Fl_Multi_Label is used in the New->Code submenu in fluid, and others.
|
||||
|
||||
Each Fl_Multi_Label holds two elements, labela and labelb; each may hold either a
|
||||
text label (const char*) or an image (Fl_Image*). When displayed, labela is drawn first
|
||||
and labelb is drawn immediately to its right.
|
||||
|
||||
More complex labels might be constructed by setting labelb as another Fl_Multi_Label and
|
||||
thus chaining up a series of label elements.
|
||||
|
||||
When assigning a label element to one of labela or labelb, they should be explicitly cast
|
||||
to (const char*) if they are not of that type already.
|
||||
|
||||
\see Fl_Label and Fl_Labeltype
|
||||
*/
|
||||
struct FL_EXPORT Fl_Multi_Label {
|
||||
/** Holds the "leftmost" of the two elements in the composite label.
|
||||
Typically this would be assigned either a text string (const char*),
|
||||
a (Fl_Image*) or a (Fl_Multi_Label*). */
|
||||
const char* labela;
|
||||
/** Holds the "rightmost" of the two elements in the composite label.
|
||||
Typically this would be assigned either a text string (const char*),
|
||||
a (Fl_Image*) or a (Fl_Multi_Label*). */
|
||||
const char* labelb;
|
||||
/** Holds the "type" of labela.
|
||||
Typically this is set to FL_NORMAL_LABEL for a text label,
|
||||
_FL_IMAGE_LABEL for an image (based on Fl_image) or _FL_MULTI_LABEL
|
||||
if "chaining" multiple Fl_Multi_Label elements together. */
|
||||
uchar typea;
|
||||
/** Holds the "type" of labelb.
|
||||
Typically this is set to FL_NORMAL_LABEL for a text label,
|
||||
_FL_IMAGE_LABEL for an image (based on Fl_image) or _FL_MULTI_LABEL
|
||||
if "chaining" multiple Fl_Multi_Label elements together. */
|
||||
uchar typeb;
|
||||
|
||||
/** This method is used to associate a Fl_Multi_Label with a Fl_Widget. */
|
||||
void label(Fl_Widget*);
|
||||
/** This method is used to associate a Fl_Multi_Label with a Fl_Menu_Item. */
|
||||
void label(Fl_Menu_Item*);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,60 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Multiline input header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2011 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Multiline_Input widget . */
|
||||
|
||||
#ifndef Fl_Multiline_Input_H
|
||||
#define Fl_Multiline_Input_H
|
||||
|
||||
#include "Fl_Input.H"
|
||||
|
||||
/**
|
||||
This input field displays '\\n' characters as new lines rather than ^J,
|
||||
and accepts the Return, Tab, and up and down arrow keys. This is for
|
||||
editing multiline text.
|
||||
|
||||
This is far from the nirvana of text editors, and is probably only
|
||||
good for small bits of text, 10 lines at most. Note that this widget
|
||||
does not support scrollbars or per-character color control.
|
||||
|
||||
If you are presenting large amounts of text and need scrollbars
|
||||
or full color control of characters, you probably want Fl_Text_Editor
|
||||
instead.
|
||||
|
||||
In FLTK 1.3.x, the default behavior of the 'Tab' key was changed
|
||||
to support consistent focus navigation. To get the older FLTK 1.1.x
|
||||
behavior, set Fl_Input_::tab_nav() to 0. Newer programs should consider using
|
||||
Fl_Text_Editor.
|
||||
*/
|
||||
class FL_EXPORT Fl_Multiline_Input : public Fl_Input {
|
||||
public:
|
||||
/**
|
||||
Creates a new Fl_Multiline_Input widget using the given
|
||||
position, size, and label string. The default boxtype is FL_DOWN_BOX.
|
||||
|
||||
Inherited destructor destroys the widget and any value associated with it.
|
||||
*/
|
||||
Fl_Multiline_Input(int X,int Y,int W,int H,const char *l = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,56 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Multi line output header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2011 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Multiline_Output widget . */
|
||||
|
||||
#ifndef Fl_Multiline_Output_H
|
||||
#define Fl_Multiline_Output_H
|
||||
|
||||
#include "Fl_Output.H"
|
||||
|
||||
/**
|
||||
This widget is a subclass of Fl_Output that displays multiple
|
||||
lines of text. It also displays tab characters as whitespace to the
|
||||
next column.
|
||||
|
||||
Note that this widget does not support scrollbars, or per-character
|
||||
color control.
|
||||
|
||||
If you are presenting large amounts of read-only text
|
||||
and need scrollbars, or full color control of characters,
|
||||
then use Fl_Text_Display. If you want to display HTML text,
|
||||
use Fl_Help_View.
|
||||
*/
|
||||
class FL_EXPORT Fl_Multiline_Output : public Fl_Output {
|
||||
public:
|
||||
|
||||
/**
|
||||
Creates a new Fl_Multiline_Output widget using the given position,
|
||||
size, and label string. The default boxtype is FL_DOWN_BOX.
|
||||
|
||||
Inherited destructor destroys the widget and any value associated with it.
|
||||
*/
|
||||
Fl_Multiline_Output(int X,int Y,int W,int H,const char *l = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,348 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// FLTK native OS file chooser widget
|
||||
//
|
||||
// Copyright 1998-2014 by Bill Spitzak and others.
|
||||
// Copyright 2004 Greg Ercolano.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/** \file
|
||||
Fl_Native_File_Chooser widget. */
|
||||
|
||||
#ifndef FL_NATIVE_FILE_CHOOSER_H
|
||||
#define FL_NATIVE_FILE_CHOOSER_H
|
||||
|
||||
// Use Windows' chooser
|
||||
#ifdef WIN32
|
||||
// #define _WIN32_WINNT 0x0501 // needed for OPENFILENAME's 'FlagsEx'
|
||||
#if defined(FL_LIBRARY) || FLTK_ABI_VERSION < 10304
|
||||
# include <windows.h>
|
||||
# include <commdlg.h> // OPENFILENAMEW, GetOpenFileName()
|
||||
# include <shlobj.h> // BROWSEINFOW, SHBrowseForFolder()
|
||||
typedef OPENFILENAMEW fl_OPENFILENAMEW;
|
||||
typedef BROWSEINFOW fl_BROWSEINFOW;
|
||||
#else
|
||||
typedef void fl_OPENFILENAMEW;
|
||||
typedef void fl_BROWSEINFOW;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Use Apple's chooser
|
||||
#ifdef __APPLE__
|
||||
# define MAXFILTERS 80
|
||||
#endif
|
||||
|
||||
// All else falls back to FLTK's own chooser
|
||||
#if ! defined(__APPLE__) && !defined(WIN32)
|
||||
# include <FL/Fl_File_Chooser.H>
|
||||
#else
|
||||
# include <FL/filename.H> // FL_EXPORT
|
||||
#endif
|
||||
|
||||
class Fl_FLTK_File_Chooser;
|
||||
class Fl_GTK_File_Chooser;
|
||||
|
||||
/**
|
||||
This class lets an FLTK application easily and consistently access
|
||||
the operating system's native file chooser. Some operating systems
|
||||
have very complex and specific file choosers that many users want
|
||||
access to specifically, instead of FLTK's default file chooser(s).
|
||||
|
||||
In cases where there is no native file browser, FLTK's own file browser
|
||||
is used instead.
|
||||
|
||||
To use this widget, use the following include in your code:
|
||||
\code
|
||||
#include <FL/Fl_Native_File_Chooser.H>
|
||||
\endcode
|
||||
|
||||
The following example shows how to pick a single file:
|
||||
\code
|
||||
// Create and post the local native file chooser
|
||||
#include <FL/Fl_Native_File_Chooser.H>
|
||||
[..]
|
||||
Fl_Native_File_Chooser fnfc;
|
||||
fnfc.title("Pick a file");
|
||||
fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE);
|
||||
fnfc.filter("Text\t*.txt\n"
|
||||
"C Files\t*.{cxx,h,c}");
|
||||
fnfc.directory("/var/tmp"); // default directory to use
|
||||
// Show native chooser
|
||||
switch ( fnfc.show() ) {
|
||||
case -1: printf("ERROR: %s\n", fnfc.errmsg()); break; // ERROR
|
||||
case 1: printf("CANCEL\n"); break; // CANCEL
|
||||
default: printf("PICKED: %s\n", fnfc.filename()); break; // FILE CHOSEN
|
||||
}
|
||||
\endcode
|
||||
|
||||
The Fl_Native_File_Chooser widget transmits UTF-8 encoded filenames to its user. It is
|
||||
recommended to open files that may have non-ASCII names with the fl_fopen() or
|
||||
fl_open() utility functions that handle these names in a cross-platform way
|
||||
(whereas the standard fopen()/open() functions fail on the MSWindows platform
|
||||
to open files with a non-ASCII name).
|
||||
|
||||
<B>Platform Specific Caveats</B>
|
||||
|
||||
- Under X windows, and if Fl::OPTION_FNFC_USES_GTK has not been switched off,
|
||||
the widget attempts to use standard GTK file chooser dialogs if they are
|
||||
available at run-time on the platform, and falls back to use FLTK's Fl_File_Chooser if they are not.
|
||||
In the latter case, it's best if you call Fl_File_Icon::load_system_icons()
|
||||
at the start of main(), to enable the nicer looking file browser widgets.
|
||||
Use the static public attributes of class Fl_File_Chooser to localize
|
||||
the browser.
|
||||
- Some operating systems support certain OS specific options; see
|
||||
Fl_Native_File_Chooser::options() for a list.
|
||||
|
||||
\image html Fl_Native_File_Chooser.png "The Fl_Native_File_Chooser on different platforms."
|
||||
\image latex Fl_Native_File_Chooser.png "The Fl_Native_File_Chooser on different platforms" width=14cm
|
||||
|
||||
*/
|
||||
class FL_EXPORT Fl_Native_File_Chooser {
|
||||
public:
|
||||
enum Type {
|
||||
BROWSE_FILE = 0, ///< browse files (lets user choose one file)
|
||||
BROWSE_DIRECTORY, ///< browse directories (lets user choose one directory)
|
||||
BROWSE_MULTI_FILE, ///< browse files (lets user choose multiple files)
|
||||
BROWSE_MULTI_DIRECTORY, ///< browse directories (lets user choose multiple directories)
|
||||
BROWSE_SAVE_FILE, ///< browse to save a file
|
||||
BROWSE_SAVE_DIRECTORY ///< browse to save a directory
|
||||
};
|
||||
enum Option {
|
||||
NO_OPTIONS = 0x0000, ///< no options enabled
|
||||
SAVEAS_CONFIRM = 0x0001, ///< Show native 'Save As' overwrite confirm dialog
|
||||
NEW_FOLDER = 0x0002, ///< Show 'New Folder' icon (if supported)
|
||||
PREVIEW = 0x0004, ///< enable preview mode (if supported)
|
||||
USE_FILTER_EXT = 0x0008 ///< Chooser filter pilots the output file extension (if supported)
|
||||
};
|
||||
/** Localizable message */
|
||||
static const char *file_exists_message;
|
||||
|
||||
public:
|
||||
Fl_Native_File_Chooser(int val=BROWSE_FILE);
|
||||
~Fl_Native_File_Chooser();
|
||||
|
||||
// Public methods
|
||||
void type(int t);
|
||||
int type() const ;
|
||||
void options(int o);
|
||||
int options() const;
|
||||
int count() const;
|
||||
const char *filename() const ;
|
||||
const char *filename(int i) const ;
|
||||
void directory(const char *val) ;
|
||||
const char *directory() const;
|
||||
void title(const char *t);
|
||||
const char* title() const;
|
||||
const char *filter() const ;
|
||||
void filter(const char *f);
|
||||
int filters() const ;
|
||||
void filter_value(int i) ;
|
||||
int filter_value() const ;
|
||||
void preset_file(const char*f) ;
|
||||
const char* preset_file() const;
|
||||
const char *errmsg() const ;
|
||||
int show() ;
|
||||
|
||||
#ifdef WIN32
|
||||
private:
|
||||
int _btype; // kind-of browser to show()
|
||||
int _options; // general options
|
||||
#if FLTK_ABI_VERSION >= 10304
|
||||
fl_OPENFILENAMEW *_ofn_ptr; // GetOpenFileName() & GetSaveFileName() struct
|
||||
fl_BROWSEINFOW *_binf_ptr; // SHBrowseForFolder() struct
|
||||
WCHAR *_wpattern; // pattern buffer for filter
|
||||
#else
|
||||
fl_OPENFILENAMEW _ofn;
|
||||
fl_BROWSEINFOW _binf;
|
||||
#endif
|
||||
char **_pathnames; // array of pathnames
|
||||
int _tpathnames; // total pathnames
|
||||
char *_directory; // default pathname to use
|
||||
char *_title; // title for window
|
||||
char *_filter; // user-side search filter
|
||||
char *_parsedfilt; // filter parsed for Windows dialog
|
||||
int _nfilters; // number of filters parse_filter counted
|
||||
char *_preset_file; // the file to preselect
|
||||
char *_errmsg; // error message
|
||||
|
||||
// Private methods
|
||||
void errmsg(const char *msg);
|
||||
|
||||
void clear_pathnames();
|
||||
void set_single_pathname(const char *s);
|
||||
void add_pathname(const char *s);
|
||||
|
||||
void ClearOFN();
|
||||
void ClearBINF();
|
||||
void Win2Unix(char *s);
|
||||
void Unix2Win(char *s);
|
||||
int showfile();
|
||||
int showdir();
|
||||
|
||||
void parse_filter(const char *);
|
||||
void clear_filters();
|
||||
void add_filter(const char *, const char *);
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
private:
|
||||
int _btype; // kind-of browser to show()
|
||||
int _options; // general options
|
||||
void *_panel;
|
||||
char **_pathnames; // array of pathnames
|
||||
int _tpathnames; // total pathnames
|
||||
char *_directory; // default pathname to use
|
||||
char *_title; // title for window
|
||||
char *_preset_file; // the 'save as' filename
|
||||
|
||||
char *_filter; // user-side search filter, eg:
|
||||
// C Files\t*.[ch]\nText Files\t*.txt"
|
||||
|
||||
char *_filt_names; // filter names (tab delimited)
|
||||
// eg. "C Files\tText Files"
|
||||
|
||||
char *_filt_patt[MAXFILTERS];
|
||||
// array of filter patterns, eg:
|
||||
// _filt_patt[0]="*.{cxx,h}"
|
||||
// _filt_patt[1]="*.txt"
|
||||
|
||||
int _filt_total; // parse_filter() # of filters loaded
|
||||
int _filt_value; // index of the selected filter
|
||||
char *_errmsg; // error message
|
||||
|
||||
// Private methods
|
||||
void errmsg(const char *msg);
|
||||
void clear_pathnames();
|
||||
void set_single_pathname(const char *s);
|
||||
int get_saveas_basename(void);
|
||||
void clear_filters();
|
||||
void add_filter(const char *, const char *);
|
||||
void parse_filter(const char *from);
|
||||
int post();
|
||||
int runmodal();
|
||||
#endif
|
||||
|
||||
#if ! defined(__APPLE__) && !defined(WIN32)
|
||||
private:
|
||||
#if FLTK_ABI_VERSION <= 10302
|
||||
int _btype; // kind-of browser to show()
|
||||
int _options; // general options
|
||||
int _nfilters;
|
||||
char *_filter; // user supplied filter
|
||||
char *_parsedfilt; // parsed filter
|
||||
int _filtvalue; // selected filter
|
||||
char *_preset_file;
|
||||
char *_prevvalue; // Returned filename
|
||||
char *_directory;
|
||||
char *_errmsg; // error message
|
||||
#endif
|
||||
static int have_looked_for_GTK_libs;
|
||||
union {
|
||||
Fl_FLTK_File_Chooser *_x11_file_chooser;
|
||||
Fl_GTK_File_Chooser *_gtk_file_chooser;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined(__APPLE__) && !defined(WIN32)
|
||||
class FL_EXPORT Fl_FLTK_File_Chooser {
|
||||
friend class Fl_Native_File_Chooser;
|
||||
protected:
|
||||
int _btype; // kind-of browser to show()
|
||||
int _options; // general options
|
||||
int _nfilters;
|
||||
char *_filter; // user supplied filter
|
||||
char *_parsedfilt; // parsed filter
|
||||
int _filtvalue; // selected filter
|
||||
char *_preset_file;
|
||||
char *_prevvalue; // Returned filename
|
||||
char *_directory;
|
||||
char *_errmsg; // error message
|
||||
Fl_FLTK_File_Chooser(int val);
|
||||
virtual ~Fl_FLTK_File_Chooser();
|
||||
void errmsg(const char *msg);
|
||||
int type_fl_file(int);
|
||||
void parse_filter();
|
||||
int exist_dialog();
|
||||
Fl_File_Chooser *_file_chooser;
|
||||
virtual void type(int);
|
||||
int type() const;
|
||||
void options(int);
|
||||
int options() const;
|
||||
virtual int count() const;
|
||||
virtual const char *filename() const;
|
||||
virtual const char *filename(int i) const;
|
||||
void directory(const char *val);
|
||||
const char *directory() const;
|
||||
virtual void title(const char *);
|
||||
virtual const char* title() const;
|
||||
const char *filter() const;
|
||||
void filter(const char *);
|
||||
int filters() const;
|
||||
void filter_value(int i);
|
||||
int filter_value() const;
|
||||
void preset_file(const char*);
|
||||
const char* preset_file() const;
|
||||
const char *errmsg() const;
|
||||
virtual int show();
|
||||
};
|
||||
|
||||
|
||||
class FL_EXPORT Fl_GTK_File_Chooser : public Fl_FLTK_File_Chooser {
|
||||
friend class Fl_Native_File_Chooser;
|
||||
private:
|
||||
typedef struct _GtkWidget GtkWidget;
|
||||
typedef struct _GtkFileFilterInfo GtkFileFilterInfo;
|
||||
struct pair {
|
||||
Fl_GTK_File_Chooser* running; // the running Fl_GTK_File_Chooser
|
||||
const char *filter; // a filter string of the chooser
|
||||
pair(Fl_GTK_File_Chooser* c, const char *f) {
|
||||
running = c;
|
||||
filter = strdup(f);
|
||||
};
|
||||
~pair() {
|
||||
free((char*)filter);
|
||||
};
|
||||
};
|
||||
GtkWidget *gtkw_ptr; // used to hold a GtkWidget* without pulling GTK into everything...
|
||||
void *gtkw_slist; // used to hold a GLib GSList...
|
||||
unsigned gtkw_count; // number of files read back - if any
|
||||
mutable char *gtkw_filename; // last name we read back
|
||||
char *gtkw_title; // the title to be applied to the dialog
|
||||
const char *previous_filter;
|
||||
|
||||
int fl_gtk_chooser_wrapper(); // method that wraps the GTK widget
|
||||
Fl_GTK_File_Chooser(int val);
|
||||
virtual ~Fl_GTK_File_Chooser();
|
||||
static int did_find_GTK_libs;
|
||||
static void probe_for_GTK_libs(void);
|
||||
virtual void type(int);
|
||||
virtual int count() const;
|
||||
virtual const char *filename() const;
|
||||
virtual const char *filename(int i) const;
|
||||
virtual void title(const char *);
|
||||
virtual const char* title() const;
|
||||
virtual int show();
|
||||
void changed_output_type(const char *filter);
|
||||
|
||||
static int custom_gtk_filter_function(const GtkFileFilterInfo*, Fl_GTK_File_Chooser::pair*);
|
||||
static void free_pair(pair *p);
|
||||
};
|
||||
#endif // !defined(__APPLE__) && !defined(WIN32)
|
||||
|
||||
#endif /*FL_NATIVE_FILE_CHOOSER_H*/
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,36 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// "Nice" slider header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Nice_Slider widget . */
|
||||
|
||||
#ifndef Fl_Nice_Slider_H
|
||||
#define Fl_Nice_Slider_H
|
||||
|
||||
#include "Fl_Slider.H"
|
||||
|
||||
class FL_EXPORT Fl_Nice_Slider : public Fl_Slider {
|
||||
public:
|
||||
Fl_Nice_Slider(int X,int Y,int W,int H,const char *L=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,27 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Old Fl_Object header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
// This file is provided for back compatibility only. Please use Fl_Widget
|
||||
#ifndef Fl_Object
|
||||
#define Fl_Object Fl_Widget
|
||||
#endif
|
||||
#include "Fl_Widget.H"
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,63 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Output header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2011 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Output widget . */
|
||||
|
||||
#ifndef Fl_Output_H
|
||||
#define Fl_Output_H
|
||||
|
||||
#include "Fl_Input.H"
|
||||
/**
|
||||
This widget displays a piece of text.
|
||||
|
||||
When you set the value() , Fl_Output does a strcpy() to its own storage,
|
||||
which is useful for program-generated values. The user may select
|
||||
portions of the text using the mouse and paste the contents into other
|
||||
fields or programs.
|
||||
|
||||
<P align=CENTER>\image html text.png</P>
|
||||
\image latex text.png "Fl_Output" width=8cm
|
||||
|
||||
There is a single subclass, Fl_Multiline_Output, which allows you to
|
||||
display multiple lines of text. Fl_Multiline_Output does not provide
|
||||
scroll bars. If a more complete text editing widget is needed, use
|
||||
Fl_Text_Display instead.
|
||||
|
||||
The text may contain any characters except \\0, and will correctly
|
||||
display anything, using ^X notation for unprintable control characters
|
||||
and \\nnn notation for unprintable characters with the high bit set. It
|
||||
assumes the font can draw any characters in the ISO-Latin1 character set.
|
||||
*/
|
||||
class FL_EXPORT Fl_Output : public Fl_Input {
|
||||
public:
|
||||
/**
|
||||
Creates a new Fl_Output widget using the given position,
|
||||
size, and label string. The default boxtype is FL_DOWN_BOX.
|
||||
|
||||
Inherited destructor destroys the widget and any value associated with it.
|
||||
*/
|
||||
|
||||
Fl_Output(int X,int Y,int W,int H, const char *l = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,81 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Overlay window header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Overlay_Window class . */
|
||||
|
||||
#ifndef Fl_Overlay_Window_H
|
||||
#define Fl_Overlay_Window_H
|
||||
|
||||
#include "Fl_Double_Window.H"
|
||||
|
||||
/**
|
||||
This window provides double buffering and also the ability to draw the
|
||||
"overlay" which is another picture placed on top of the main image. The
|
||||
overlay is designed to be a rapidly-changing but simple graphic such as
|
||||
a mouse selection box. Fl_Overlay_Window uses the overlay
|
||||
planes provided by your graphics hardware if they are available.
|
||||
<P>If no hardware support is found the overlay is simulated by drawing
|
||||
directly into the on-screen copy of the double-buffered window, and
|
||||
"erased" by copying the backbuffer over it again. This means the
|
||||
overlay will blink if you change the image in the window.
|
||||
*/
|
||||
class FL_EXPORT Fl_Overlay_Window : public Fl_Double_Window {
|
||||
#ifndef FL_DOXYGEN
|
||||
friend class _Fl_Overlay;
|
||||
#endif
|
||||
protected:
|
||||
/**
|
||||
You must subclass Fl_Overlay_Window and provide this method.
|
||||
It is just like a draw() method, except it draws the overlay.
|
||||
The overlay will have already been "cleared" when this is called. You
|
||||
can use any of the routines described in <FL/fl_draw.H>.
|
||||
*/
|
||||
virtual void draw_overlay() = 0;
|
||||
private:
|
||||
Fl_Window *overlay_;
|
||||
public:
|
||||
void show();
|
||||
void flush();
|
||||
void hide();
|
||||
void resize(int,int,int,int);
|
||||
~Fl_Overlay_Window();
|
||||
/** Returns non-zero if there's hardware overlay support */
|
||||
int can_do_overlay();
|
||||
void redraw_overlay();
|
||||
protected:
|
||||
/**
|
||||
See Fl_Overlay_Window::Fl_Overlay_Window(int X, int Y, int W, int H, const char *l=0)
|
||||
*/
|
||||
Fl_Overlay_Window(int W, int H, const char *l=0);
|
||||
/**
|
||||
Creates a new Fl_Overlay_Window widget using the given
|
||||
position, size, and label (title) string. If the
|
||||
positions (x,y) are not given, then the window manager
|
||||
will choose them.
|
||||
*/
|
||||
Fl_Overlay_Window(int X, int Y, int W, int H, const char *l=0);
|
||||
public:
|
||||
void show(int a, char **b) {Fl_Double_Window::show(a,b);}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,46 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// PNG image header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_PNG_Image class . */
|
||||
|
||||
#ifndef Fl_PNG_Image_H
|
||||
#define Fl_PNG_Image_H
|
||||
# include "Fl_Image.H"
|
||||
|
||||
/**
|
||||
The Fl_PNG_Image class supports loading, caching,
|
||||
and drawing of Portable Network Graphics (PNG) image files. The
|
||||
class loads colormapped and full-color images and handles color-
|
||||
and alpha-based transparency.
|
||||
*/
|
||||
class FL_EXPORT Fl_PNG_Image : public Fl_RGB_Image {
|
||||
|
||||
public:
|
||||
|
||||
Fl_PNG_Image(const char* filename);
|
||||
Fl_PNG_Image (const char *name_png, const unsigned char *buffer, int datasize);
|
||||
private:
|
||||
void load_png_(const char *name_png, const unsigned char *buffer_png, int datasize);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// PNM image header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_PNM_Image class . */
|
||||
|
||||
#ifndef Fl_PNM_Image_H
|
||||
#define Fl_PNM_Image_H
|
||||
# include "Fl_Image.H"
|
||||
|
||||
/**
|
||||
The Fl_PNM_Image class supports loading, caching,
|
||||
and drawing of Portable Anymap (PNM, PBM, PGM, PPM) image files. The class
|
||||
loads bitmap, grayscale, and full-color images in both ASCII and
|
||||
binary formats.
|
||||
*/
|
||||
class FL_EXPORT Fl_PNM_Image : public Fl_RGB_Image {
|
||||
|
||||
public:
|
||||
|
||||
Fl_PNM_Image(const char* filename);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,75 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Pack header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Pack widget . */
|
||||
|
||||
#ifndef Fl_Pack_H
|
||||
#define Fl_Pack_H
|
||||
|
||||
#include <FL/Fl_Group.H>
|
||||
|
||||
/**
|
||||
This widget was designed to add the functionality of compressing and
|
||||
aligning widgets.
|
||||
<P>If type() is Fl_Pack::HORIZONTAL all the children are
|
||||
resized to the height of the Fl_Pack, and are moved next to
|
||||
each other horizontally. If type() is not Fl_Pack::HORIZONTAL
|
||||
then the children are resized to the width and are stacked below each
|
||||
other. Then the Fl_Pack resizes itself to surround the child
|
||||
widgets.
|
||||
<P>This widget is needed for the Fl_Tabs.
|
||||
In addition you may want to put the Fl_Pack inside an
|
||||
Fl_Scroll.
|
||||
|
||||
<P>The resizable for Fl_Pack is set to NULL by default.</p>
|
||||
<P>See also: Fl_Group::resizable()
|
||||
*/
|
||||
class FL_EXPORT Fl_Pack : public Fl_Group {
|
||||
int spacing_;
|
||||
|
||||
public:
|
||||
enum { // values for type(int)
|
||||
VERTICAL = 0,
|
||||
HORIZONTAL = 1
|
||||
};
|
||||
|
||||
protected:
|
||||
void draw();
|
||||
|
||||
public:
|
||||
Fl_Pack(int x,int y,int w ,int h,const char *l = 0);
|
||||
/**
|
||||
Gets the number of extra pixels of blank space that are added
|
||||
between the children.
|
||||
*/
|
||||
int spacing() const {return spacing_;}
|
||||
/**
|
||||
Sets the number of extra pixels of blank space that are added
|
||||
between the children.
|
||||
*/
|
||||
void spacing(int i) {spacing_ = i;}
|
||||
/** Same as Fl_Group::type() */
|
||||
uchar horizontal() const {return type();}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
|
@ -1,155 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Printing support for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2010-2016 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/** \file Fl_Paged_Device.H
|
||||
\brief declaration of class Fl_Paged_Device.
|
||||
*/
|
||||
|
||||
#ifndef Fl_Paged_Device_H
|
||||
#define Fl_Paged_Device_H
|
||||
|
||||
#include <FL/Fl_Device.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
|
||||
/** \brief Number of elements in enum Page_Format */
|
||||
#define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */
|
||||
|
||||
/**
|
||||
\brief Represents page-structured drawing surfaces.
|
||||
*
|
||||
This class has no public constructor: don't instantiate it; use Fl_Printer
|
||||
or Fl_PostScript_File_Device instead.
|
||||
*/
|
||||
class FL_EXPORT Fl_Paged_Device : public Fl_Surface_Device {
|
||||
#ifndef __APPLE__
|
||||
friend class Fl_Copy_Surface;
|
||||
friend class Fl_Image_Surface;
|
||||
void draw_decorated_window(Fl_Window *win, int x_offset, int y_offset, Fl_Surface_Device *toset);
|
||||
#endif
|
||||
public:
|
||||
/**
|
||||
\brief Possible page formats.
|
||||
|
||||
All paper formats with pre-defined width and height.
|
||||
*/
|
||||
enum Page_Format {
|
||||
A0 = 0, /**< A0 format */
|
||||
A1,
|
||||
A2,
|
||||
A3,
|
||||
A4, /**< A4 format */
|
||||
A5,
|
||||
A6,
|
||||
A7,
|
||||
A8,
|
||||
A9,
|
||||
B0,
|
||||
B1,
|
||||
B2,
|
||||
B3,
|
||||
B4,
|
||||
B5,
|
||||
B6,
|
||||
B7,
|
||||
B8,
|
||||
B9,
|
||||
B10,
|
||||
C5E,
|
||||
DLE,
|
||||
EXECUTIVE,
|
||||
FOLIO,
|
||||
LEDGER,
|
||||
LEGAL,
|
||||
LETTER, /**< Letter format */
|
||||
TABLOID,
|
||||
ENVELOPE,
|
||||
MEDIA = 0x1000
|
||||
};
|
||||
/**
|
||||
\brief Possible page layouts.
|
||||
*/
|
||||
enum Page_Layout {
|
||||
PORTRAIT = 0, /**< Portrait orientation */
|
||||
LANDSCAPE = 0x100, /**< Landscape orientation */
|
||||
REVERSED = 0x200, /**< Reversed orientation */
|
||||
ORIENTATION = 0x300 /**< orientation */
|
||||
};
|
||||
|
||||
/** \brief width, height and name of a page format
|
||||
*/
|
||||
typedef struct {
|
||||
/** \brief width in points */
|
||||
int width;
|
||||
/** \brief height in points */
|
||||
int height;
|
||||
/** \brief format name */
|
||||
const char *name;
|
||||
} page_format;
|
||||
/** \brief width, height and name of all elements of the enum \ref Page_Format.
|
||||
*/
|
||||
static const page_format page_formats[NO_PAGE_FORMATS];
|
||||
private:
|
||||
void traverse(Fl_Widget *widget); // finds subwindows of widget and prints them
|
||||
protected:
|
||||
/** \brief horizontal offset to the origin of graphics coordinates */
|
||||
int x_offset;
|
||||
/** \brief vertical offset to the origin of graphics coordinates */
|
||||
int y_offset;
|
||||
/** \brief The constructor */
|
||||
Fl_Paged_Device() : Fl_Surface_Device(NULL), x_offset(0), y_offset(0) {};
|
||||
#if FLTK_ABI_VERSION >= 10301
|
||||
public:
|
||||
/** \brief The destructor */
|
||||
virtual ~Fl_Paged_Device() {};
|
||||
#else
|
||||
/** \brief The destructor */
|
||||
virtual ~Fl_Paged_Device() {};
|
||||
public:
|
||||
#endif // FLTK_ABI_VERSION
|
||||
static const char *class_id;
|
||||
const char *class_name() {return class_id;};
|
||||
virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
|
||||
virtual int start_page(void);
|
||||
virtual int printable_rect(int *w, int *h);
|
||||
virtual void margins(int *left, int *top, int *right, int *bottom);
|
||||
virtual void origin(int x, int y);
|
||||
virtual void origin(int *x, int *y);
|
||||
virtual void scale(float scale_x, float scale_y = 0.);
|
||||
virtual void rotate(float angle);
|
||||
virtual void translate(int x, int y);
|
||||
virtual void untranslate(void);
|
||||
virtual void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0);
|
||||
/** Prints a window with its title bar and frame if any.
|
||||
|
||||
\p x_offset and \p y_offset are optional coordinates of where to position the window top left.
|
||||
Equivalent to print_widget() if \p win is a subwindow or has no border.
|
||||
Use Fl_Window::decorated_w() and Fl_Window::decorated_h() to get the size of the
|
||||
printed window.
|
||||
*/
|
||||
void print_window(Fl_Window *win, int x_offset = 0, int y_offset = 0);
|
||||
virtual void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x = 0, int delta_y = 0);
|
||||
virtual int end_page (void);
|
||||
virtual void end_job (void);
|
||||
};
|
||||
|
||||
#endif // Fl_Paged_Device_H
|
||||
|
||||
//
|
||||
// End of "$Id$"
|
||||
//
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// Pixmap header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2012 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Pixmap widget . */
|
||||
|
||||
#ifndef Fl_Pixmap_H
|
||||
#define Fl_Pixmap_H
|
||||
# include "Fl_Image.H"
|
||||
#if defined(WIN32)
|
||||
# include "x.H"
|
||||
#endif
|
||||
|
||||
class Fl_Widget;
|
||||
struct Fl_Menu_Item;
|
||||
|
||||
// Older C++ compilers don't support the explicit keyword... :(
|
||||
# if defined(__sgi) && !defined(_COMPILER_VERSION)
|
||||
# define explicit
|
||||
# endif // __sgi && !_COMPILER_VERSION
|
||||
|
||||
/**
|
||||
The Fl_Pixmap class supports caching and drawing of colormap
|
||||
(pixmap) images, including transparency.
|
||||
*/
|
||||
class FL_EXPORT Fl_Pixmap : public Fl_Image {
|
||||
friend class Fl_Quartz_Graphics_Driver;
|
||||
friend class Fl_GDI_Graphics_Driver;
|
||||
friend class Fl_GDI_Printer_Graphics_Driver;
|
||||
friend class Fl_Xlib_Graphics_Driver;
|
||||
void copy_data();
|
||||
void delete_data();
|
||||
void set_data(const char * const *p);
|
||||
int prepare(int XP, int YP, int WP, int HP, int &cx, int &cy,
|
||||
int &X, int &Y, int &W, int &H);
|
||||
|
||||
protected:
|
||||
|
||||
void measure();
|
||||
|
||||
public:
|
||||
|
||||
int alloc_data; // Non-zero if data was allocated
|
||||
|
||||
private:
|
||||
|
||||
#if defined(WIN32)
|
||||
#if FLTK_ABI_VERSION < 10301
|
||||
static // a static member is needed for ABI compatibility
|
||||
#endif
|
||||
UINT pixmap_bg_color; // RGB color used for pixmap background
|
||||
#endif // WIN32
|
||||
#if defined(__APPLE__) || defined(WIN32)
|
||||
void *id_; // for internal use
|
||||
void *mask_; // for internal use (mask bitmap)
|
||||
#else
|
||||
unsigned id_; // for internal use
|
||||
unsigned mask_; // for internal use (mask bitmap)
|
||||
#endif // __APPLE__ || WIN32
|
||||
|
||||
public:
|
||||
|
||||
/** The constructors create a new pixmap from the specified XPM data. */
|
||||
explicit Fl_Pixmap(char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
|
||||
/** The constructors create a new pixmap from the specified XPM data. */
|
||||
explicit Fl_Pixmap(uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
|
||||
/** The constructors create a new pixmap from the specified XPM data. */
|
||||
explicit Fl_Pixmap(const char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
|
||||
/** The constructors create a new pixmap from the specified XPM data. */
|
||||
explicit Fl_Pixmap(const uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
|
||||
virtual ~Fl_Pixmap();
|
||||
virtual Fl_Image *copy(int W, int H);
|
||||
Fl_Image *copy() { return copy(w(), h()); }
|
||||
virtual void color_average(Fl_Color c, float i);
|
||||
virtual void desaturate();
|
||||
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
|
||||
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
|
||||
virtual void label(Fl_Widget*w);
|
||||
virtual void label(Fl_Menu_Item*m);
|
||||
virtual void uncache();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue