Merge branch 'zynaddsubfx-master'

* zynaddsubfx-master:
  FLTK/CMakeLists.txt: fix CMAKE_MODULE_PATH, don't use 3rdparty code
  ZynAddSubFX/FLTK: updated to SVN revision 7680
  ZynAddSubFX: check whether QDomDocument::setContent() succeeded
  ZynAddSubFX: completely reinitialize config after changing working dir
  ZynAddSubFX: set working directory before setting preset directory
  ZynAddSubFX/CMakeLists.txt: use global binary dir as last include dir
  ZynAddSubFX/CMakeLists.txt: remove accidently added subdirectory
  ZynAddSubFX: resynced with upstream (version 2.4.1)
  ZynAddSubFX/FLTK: updated to SVN revision 6970
  Misc: Minor changes to filter_ to reduce warnings (cherry picked from commit e2b1eb9b1077e6516c0cc4e2283e5c886bed0e58)
  Cleanup: Separated Presets into Presets/PresetsArray
  ZynAddSubFX: fixed commit d61283ad93
  ZynAddSubFX/FLTK: updated to SVN revision 6943
  small changelog fix (cherry picked from commit c8d411b5f7e7a295286c1ac2c09ae22f15a1db51)
  VirKeyboard: Fixed possible segfault
  small changes on Bandwidth on Reverb (cherry picked from commit d0b0a4e00a44559a4e78035fd04568bd4bab9651)
  ZynAddSubFX: new QtXmlWrapper, a QtXml-based XML backend for ZASF
(cherry picked from commit 278b70384e)
This commit is contained in:
Tobias Doerffel
2010-07-26 15:14:38 +02:00
parent e8c8054535
commit 3929848ec4
315 changed files with 25178 additions and 15157 deletions

View File

@@ -24,19 +24,6 @@ SET(ZYN_SRC_GUI
)
SET(MXML_SRC
${CMAKE_CURRENT_SOURCE_DIR}/mxml/mxml-attr.c
${CMAKE_CURRENT_SOURCE_DIR}/mxml/mxml-entity.c
${CMAKE_CURRENT_SOURCE_DIR}/mxml/mxml-file.c
${CMAKE_CURRENT_SOURCE_DIR}/mxml/mxml-index.c
${CMAKE_CURRENT_SOURCE_DIR}/mxml/mxml-node.c
${CMAKE_CURRENT_SOURCE_DIR}/mxml/mxml-private.c
${CMAKE_CURRENT_SOURCE_DIR}/mxml/mxml-search.c
${CMAKE_CURRENT_SOURCE_DIR}/mxml/mxml-set.c
${CMAKE_CURRENT_SOURCE_DIR}/mxml/mxml-string.c
)
# definitions for ZynAddSubFX
IF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE)
ADD_DEFINITIONS(-DOS_LINUX)
@@ -60,7 +47,7 @@ IF(LMMS_BUILD_WIN32)
ADD_DEFINITIONS(-DPTW32_STATIC_LIB)
ENDIF(LMMS_BUILD_WIN32)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/fltk/ ${CMAKE_CURRENT_SOURCE_DIR}/mxml ${CMAKE_CURRENT_SOURCE_DIR} ${FFTW3F_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/fltk/ ${CMAKE_CURRENT_SOURCE_DIR} ${FFTW3F_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} )
set(ZASF_CORE_LIBS
zynaddsubfx_input
@@ -72,7 +59,6 @@ set(ZASF_CORE_LIBS
zynaddsubfx_params
zynaddsubfx_dsp
zynaddsubfx_samples
zynaddsubfx_controls
)
macro(unit_test NAME CXX_FILE FILES)
@@ -80,7 +66,6 @@ endmacro(unit_test)
add_subdirectory(src/Misc)
add_subdirectory(src/Input)
add_subdirectory(src/Controls)
add_subdirectory(src/Synth)
add_subdirectory(src/Output)
add_subdirectory(src/Seq)
@@ -89,8 +74,8 @@ add_subdirectory(src/Params)
add_subdirectory(src/DSP)
add_subdirectory(src/Samples)
ADD_LIBRARY(ZynAddSubFxCore SHARED LocalZynAddSubFx.cpp ${MXML_SRC})
TARGET_LINK_LIBRARIES(ZynAddSubFxCore ${ZASF_CORE_LIBS} ${FFTW3F_LIBRARIES} -lz -lpthread)
ADD_LIBRARY(ZynAddSubFxCore SHARED LocalZynAddSubFx.cpp)
TARGET_LINK_LIBRARIES(ZynAddSubFxCore ${ZASF_CORE_LIBS} ${FFTW3F_LIBRARIES} ${QT_LIBRARIES} -lz -lpthread)
IF(LMMS_BUILD_WIN32)
TARGET_LINK_LIBRARIES(ZynAddSubFxCore -lws2_32)
INSTALL(TARGETS ZynAddSubFxCore DESTINATION ${PLUGIN_DIR})
@@ -115,10 +100,7 @@ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PLUGIN_DIR}")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
ADD_EXECUTABLE(RemoteZynAddSubFx RemoteZynAddSubFx.cpp ${ZYN_SRC_GUI} ${WINRC})
INSTALL(TARGETS RemoteZynAddSubFx RUNTIME DESTINATION ${PLUGIN_DIR})
IF(LMMS_BUILD_LINUX)
SET(FONTCONFIG_LIBS -lfontconfig)
ENDIF(LMMS_BUILD_LINUX)
TARGET_LINK_LIBRARIES(RemoteZynAddSubFx -lpthread ${FONTCONFIG_LIBS} -L${CMAKE_CURRENT_BINARY_DIR} -lZynAddSubFxCore ${CMAKE_CURRENT_BINARY_DIR}/fltk/bin/libfltk.a)
TARGET_LINK_LIBRARIES(RemoteZynAddSubFx -lpthread -L${CMAKE_CURRENT_BINARY_DIR} -lZynAddSubFxCore ${CMAKE_CURRENT_BINARY_DIR}/fltk/lib/libfltk.a)
ADD_DEPENDENCIES(RemoteZynAddSubFx ZynAddSubFxCore)
# link system libraries when on win32
@@ -130,7 +112,7 @@ ENDIF(LMMS_BUILD_WIN32)
IF(LMMS_BUILD_LINUX)
FIND_PACKAGE(X11)
FIND_PACKAGE(Freetype)
TARGET_LINK_LIBRARIES(RemoteZynAddSubFx ${X11_LIBRARIES} ${X11_Xft_LIB} ${FREETYPE_LIBRARY})
TARGET_LINK_LIBRARIES(RemoteZynAddSubFx -ldl ${X11_LIBRARIES} ${X11_Xft_LIB} ${X11_Xinerama_LIB} ${FREETYPE_LIBRARY} -lfontconfig)
ENDIF(LMMS_BUILD_LINUX)
@@ -144,7 +126,7 @@ IF(LMMS_BUILD_WIN64)
ELSEIF(LMMS_BUILD_WIN32)
SET(FLTK_EXTRA_FLAGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/cmake/modules/Win32Toolchain.cmake")
ENDIF(LMMS_BUILD_WIN64)
ADD_CUSTOM_TARGET(libfltk COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/fltk && cd ${CMAKE_CURRENT_BINARY_DIR}/fltk && ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/fltk ${FLTK_EXTRA_FLAGS} -DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/cmake/modules/ -DFLTK_USE_SYSTEM_ZLIB:BOOL=ON -DFLTK_USE_SYSTEM_JPEG:BOOL=ON -DFLTK_USE_SYSTEM_PNG:BOOL=ON -DUSE_OPENGL:BOOL=OFF -DBUILD_TESTING:BOOL=OFF -DCMAKE_BUILD_TYPE=release && ${CMAKE_BUILD_TOOL})
ADD_CUSTOM_TARGET(libfltk COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/fltk && cd ${CMAKE_CURRENT_BINARY_DIR}/fltk && ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/fltk ${FLTK_EXTRA_FLAGS} -DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/cmake/modules/ -DFLTK_USE_SYSTEM_ZLIB:BOOL=ON -DFLTK_USE_SYSTEM_JPEG:BOOL=ON -DFLTK_USE_SYSTEM_PNG:BOOL=ON -DOPTION_BUILD_EXAMPLES:BOOL=OFF -DCMAKE_BUILD_TYPE=release && ${CMAKE_BUILD_TOOL})
ADD_DEPENDENCIES(RemoteZynAddSubFx libfltk)
ENDIF(LMMS_HAVE_FFTW3F)

View File

@@ -828,6 +828,8 @@
- Codul de recorder wav a fost rescris
- Adaugata functia de export la sample-urile din PADsynth
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
20 Feb 2009 (Mark McCurry)
- Made several functions accept 'constant char' over 'char' to
prevent warnings
@@ -957,3 +959,18 @@
09 Oct 2009 (Mark McCurry)
- Restylized codebase with uncrustify
28 Oct 2009 (Paul Nasca)
- Disable "bw" control on Reverb when Bandwidth mode is not enabled
18 Nov 2009 (Mark McCurry)
- Fixed segfault in VirKeyBoard
02 Dec 2009 (Paul Nasca)
- Fixed a small typo on Virtual Keyboard
10 Dec 2009 (Mark McCurry)
- Separated out Presets and arrayed Presets to reduce warnings from
the Wextra flag
- Minor change to Filter_ and FormantFilter to reduce unwanted warnings

View File

@@ -49,10 +49,9 @@ LocalZynAddSubFx::LocalZynAddSubFx()
pthread_win32_thread_attach_np();
#endif
config.init();
OSCIL_SIZE = config.cfg.OscilSize;
initConfig();
config.cfg.GzipCompression = 0;
OSCIL_SIZE = config.cfg.OscilSize;
srand( time( NULL ) );
denormalkillbuf = new REALTYPE[SOUND_BUFFER_SIZE];
@@ -83,6 +82,16 @@ LocalZynAddSubFx::~LocalZynAddSubFx()
void LocalZynAddSubFx::initConfig()
{
config.init();
config.cfg.GzipCompression = 0;
}
void LocalZynAddSubFx::setSampleRate( int _sampleRate )
{
SAMPLE_RATE = _sampleRate;
@@ -173,7 +182,8 @@ void LocalZynAddSubFx::setLmmsWorkingDir( const std::string & _dir )
free( config.workingDir );
}
config.workingDir = strdup( _dir.c_str() );
config.init();
initConfig();
}

View File

@@ -35,6 +35,8 @@ public:
LocalZynAddSubFx();
~LocalZynAddSubFx();
void initConfig();
void setSampleRate( int _sampleRate );
void setBufferSize( int _bufferSize );

View File

@@ -152,17 +152,12 @@ void ZynAddSubFxInstrument::saveSettings( QDomDocument & _doc,
}
m_pluginMutex.unlock();
QByteArray a = tf.readAll();
// remove first blank line
a.remove( 0,
#ifdef LMMS_BUILD_WIN32
2
#else
1
#endif
);
QDomDocument doc( "mydoc" );
doc.setContent( a );
_this.appendChild( doc.documentElement() );
if( doc.setContent( a ) )
{
QDomNode n = _doc.importNode( doc.documentElement(), true );
_this.appendChild( n );
}
}
}
@@ -183,7 +178,6 @@ void ZynAddSubFxInstrument::loadSettings( const QDomElement & _this )
if( tf.open() )
{
QByteArray a = doc.toString( 0 ).toUtf8();
a.prepend( "<?xml version=\"1.0\"?>\n" );
tf.write( a );
tf.flush();
@@ -316,17 +310,17 @@ void ZynAddSubFxInstrument::initPlugin()
m_remotePlugin->lock();
m_remotePlugin->waitForInitDone( false );
m_remotePlugin->sendMessage(
RemotePlugin::message( IdZasfLmmsWorkingDirectory ).
addString(
QSTR_TO_STDSTR(
QString( configManager::inst()->workingDir() ) ) ) );
m_remotePlugin->sendMessage(
RemotePlugin::message( IdZasfPresetDirectory ).
addString(
QSTR_TO_STDSTR(
QString( configManager::inst()->factoryPresetsDir() +
QDir::separator() + "ZynAddSubFX" ) ) ) );
m_remotePlugin->sendMessage(
RemotePlugin::message( IdZasfLmmsWorkingDirectory ).
addString(
QSTR_TO_STDSTR(
QString( configManager::inst()->workingDir() ) ) ) );
m_remotePlugin->showUI();
m_remotePlugin->unlock();
}

View File

@@ -1,5 +1,50 @@
CHANGES IN FLTK 1.3.0
- Fixed X11/XDBE double buffering (STR #2152, #2197)
- Added new label and image alignments (STR #2269)
- Added documentation for event delivery (STR #1983)
- Fixed menu and tooltip window animation bug under X11 (compiz)
by setting an appropriate window type (STR #2082)
- redesigned CMake files (STR #2317).
- Fixed max. fd calculation, if USE_POLL is enabled (STR #2324)
- Fixed clipping for offscreen rendering (OSX, STR #2330)
- Added printing support (Fl_Printer class and friends) for native
printing on Windows and Mac OS X, PostScript printing on X11
with CUPS or lp, and PostScript file output on all platforms
- Added basic Fl_Device abstraction layer for all drawing functions
- Fixed possibility of wrong flags() in Fl_Window::iconlabel()
(STR #2161)
- Fixed Scrollbar events when max is less than min (STR #2283)
- Added argument-less constructor in Fuid Widget Class
- Fixed menu item counting issue in Fluid (STR #2322)
- Added Fl_Menu_::find_item by callback
- Removed redundant Fl_Group casts
- Added indexing to Fl_Preferences
- Integrated default menu into Demo test app
- Added automated Xcode IDE file generation to Fluid
- Fixed lost top item in Fluid's tree browser (STR #2233)
- Fixed crash in test/Editor when freeing buffer
too soon (STR #2294)
- Fixed Fl_Preferences Cygwin wide character bug (STR #2164)
- Fixed sorting in Fl_Browser - last item would not
be sorted (STR #2300)
- Fixed window levels in OS X Cocoa (STR #2316)
- Added jpeg support to Fluid image() element
- Added loading jpeg images from memory
- Added binary data type to Fluid
- File chosser preview would hang if a device was choosen
- Replaced _WIN32 symbols that had come with UTF-8 and the
new Fl_Table widget with WIN32
- Fixed a buffer overflow in fl_utf8from_mb() (STR #2279)
- Fixed a Windows GDI leak when testing alpha blending capabilities
- Fixed a name conflict with new (VS 2008 Express) winsock2.h
versions and another conflict that produced compile errors
with VS 2008 Express (STR #2301)
- Widgets now remove stale entries from the default callback
queue when they are deleted (STR #2302)
- Moved OS X code base to the more moder Cocoa toolkit thanks
to the awesome work of Manolo Gouy (STR #2221)
- Added template to generate new projects with Xcode.
- Managing all Widget flags in a single location now (STR #2161)
- Fixed all color related call to Fl_Color type (STR #2208)
- File chooser preview now recognizes utf8 encoded
@@ -113,6 +158,9 @@ CHANGES IN FLTK 1.3.0
- hide() and show() methods are now virtual from Fl_Widget,
was only virtual since Fl_Window derived classes before.
So now widget->hide() will work if widget is a window.
- New widgets: Fl_Tree, Fl_Table, Fl_Native_File_Chooser
- added Fl_Menu_ methods: insert(), find_index(), clear_submenu()
- Bug reports/enhancements now refer to the STR form http://www.fltk.org/str.php
CHANGES IN FLTK 1.1.9

View File

@@ -1,54 +0,0 @@
#
# Check if the symbol exists in include files
#
# CHECK_FUNCTIONWITHHEADER_EXISTS - macro which checks the symbol exists in include files.
# SYMBOL - symbol
# FILES - include files to check
# VARIABLE - variable to return result
#
MACRO(CHECK_FUNCTIONWITHHEADER_EXISTS SYMBOL FILES VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
SET(CHECK_SYMBOL_EXISTS_CONTENT "/* */\n")
SET(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
IF(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_SYMBOL_EXISTS_LIBS
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ENDIF(CMAKE_REQUIRED_LIBRARIES)
FOREACH(FILE ${FILES})
SET(CHECK_SYMBOL_EXISTS_CONTENT
"${CHECK_SYMBOL_EXISTS_CONTENT}#include <${FILE}>\n")
ENDFOREACH(FILE)
SET(CHECK_SYMBOL_EXISTS_CONTENT
"${CHECK_SYMBOL_EXISTS_CONTENT}\nint main()\n{\n${SYMBOL};return 0;\n}\n")
FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c
"${CHECK_SYMBOL_EXISTS_CONTENT}")
MESSAGE(STATUS "Looking for ${SYMBOL}")
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS}
"${CHECK_SYMBOL_EXISTS_LIBS}"
OUTPUT_VARIABLE OUTPUT)
IF(${VARIABLE})
MESSAGE(STATUS "Looking for ${SYMBOL} - found")
SET(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL}")
FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
"Determining if the ${SYMBOL} "
"exist passed with the following output:\n"
"${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c:\n"
"${CHECK_SYMBOL_EXISTS_CONTENT}\n")
ELSE(${VARIABLE})
MESSAGE(STATUS "Looking for ${SYMBOL} - not found.")
SET(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}")
FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
"Determining if the ${SYMBOL} "
"exist failed with the following output:\n"
"${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c:\n"
"${CHECK_SYMBOL_EXISTS_CONTENT}\n")
ENDIF(${VARIABLE})
ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
ENDMACRO(CHECK_FUNCTIONWITHHEADER_EXISTS)

View File

@@ -1,37 +1,38 @@
#-----------------------------------------------------------------------------
#
# FLTKConfig.cmake - FLTK CMake configuration file for external projects.
#
# This file is configured by FLTK and used by the UseFLTK.cmake module
# to load FLTK's settings for an external project.
# The FLTK source tree.
SET(FLTK_SOURCE_DIR "@FLTK_SOURCE_DIR@")
set(FLTK_FOUND TRUE)
set(FLTK_VERSION @FLTK_VERSION_FULL@)
# The FLTK include file directories.
SET(FLUID_COMMAND "@FLTK_FLUID_COMMAND@")
SET(FLTK_EXECUTABLE_DIRS "@FLTK_EXECUTABLE_DIRS@")
SET(FLTK_LIBRARY_DIRS "@FLTK_LIBRARY_DIRS@")
SET(FLTK_LIBRARIES "@FLTK_LIBRARIES@")
SET(FLTK_INCLUDE_DIRS "@FLTK_INCLUDE_DIRS@")
set(FLTK_FLUID_EXECUTABLE "@PREFIX_BIN@/fluid")
# The C and C++ flags added by FLTK to the cmake-configured flags.
SET(FLTK_REQUIRED_C_FLAGS "@FLTK_REQUIRED_C_FLAGS@")
SET(FLTK_REQUIRED_CXX_FLAGS "@FLTK_REQUIRED_CXX_FLAGS@")
if(NOT "@EXE_LINKER_FLAGS@" STREQUAL "")
set(FLTK_EXE_LINKER_FLAGS "@EXE_LINKER_FLAGS@")
endif(NOT "@EXE_LINKER_FLAGS@" STREQUAL "")
# The FLTK version number
SET(FLTK_VERSION_MAJOR "@FLTK_VERSION_MAJOR@")
SET(FLTK_VERSION_MINOR "@FLTK_VERSION_MINOR@")
SET(FLTK_VERSION_PATCH "@FLTK_VERSION_PATCH@")
set(FLTK_USE_FILE "@PREFIX_CONFIG@/UseFLTK.cmake")
# Is FLTK using shared libraries?
SET(FLTK_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
SET(FLTK_BUILD_SETTINGS_FILE "@FLTK_BUILD_SETTINGS_FILE@")
set(FLTK_DIR "@PREFIX_CONFIG@")
# The location of the UseFLTK.cmake file.
SET(FLTK11_USE_FILE "@FLTK_USE_FILE@")
set(FLTK_BIN_DIR "@PREFIX_BIN@")
set(FLTK_LIB_DIR "@PREFIX_LIB@")
set(FLTK_INCLUDE_DIR "@PREFIX_INCLUDE@")
set(FLTK_DATA_DIR "@PREFIX_DATA@")
set(FLTK_DOC_DIR "@PREFIX_DOC@")
# The ExodusII library dependencies.
IF(NOT FLTK_NO_LIBRARY_DEPENDS)
INCLUDE("@FLTK_LIBRARY_DEPENDS_FILE@")
ENDIF(NOT FLTK_NO_LIBRARY_DEPENDS)
set(FLTK_SHARED_LIBS_FOUND @OPTION_BUILD_SHARED_LIBS@)
set(FLTK_CAIRO_FOUND @FLTK_CAIRO_FOUND@)
set(FLTK_GL_FOUND @FLTK_GL_FOUND@)
set(FLTK_THREADS_FOUND @FLTK_THREADS_FOUND@)
set(FLTK_PTHREADS_FOUND @FLTK_PTHREADS_FOUND@)
set(FLTK_BUILTIN_JPEG_FOUND @FLTK_BUILTIN_JPEG_FOUND@)
set(FLTK_BUILTIN_ZLIB_FOUND @FLTK_BUILTIN_ZLIB_FOUND@)
set(FLTK_BUILTIN_PNG_FOUND @FLTK_BUILTIN_PNG_FOUND@)
set(FLTK_XINERAMA_FOUND @FLTK_XINERAMA_FOUND@)
set(FLTK_XFT_FOUND @FLTK_XFT_FOUND@)
set(FLTK_XDBE_FOUND @FLTK_XDBE_FOUND@)
include("@PREFIX_CONFIG@/FLTKLibraries.cmake")

View File

@@ -1,68 +0,0 @@
IF(NOT FLTK11_FOUND)
MESSAGE(FATAL_ERROR "Something went wrong. You are including FLTKUse.cmake but FLTK was not found")
ENDIF(NOT FLTK11_FOUND)
# -------------------------------------------------------------
# This macro automates wrapping of Fluid files
# Specify the output variable name and the list of sources
# The output variable can be directly added to the target.
#
# For example:
# FLTK_WRAP_FLUID(CubeView_SRCS CubeViewUI.fl)
# ADD_EXECUTABLE(CubeView CubeMain.cxx CubeView.cxx CubeView.h ${CubeView_SRCS})
# -------------------------------------------------------------
MACRO(FLTK_WRAP_FLUID VARIABLE)
FOREACH(src ${ARGN})
IF("${src}" MATCHES ".fl$")
GET_FILENAME_COMPONENT(fname ${src} NAME_WE)
GET_FILENAME_COMPONENT(fpath ${src} PATH)
GET_SOURCE_FILE_PROPERTY(gen ${src} GENERATED)
IF(gen)
SET(fluid_name "${src}")
ELSE(gen)
SET(fluid_name "${CMAKE_CURRENT_SOURCE_DIR}/${fpath}/${fname}.fl")
IF(NOT EXISTS "${fluid_name}")
SET(fluid_name "${CMAKE_CURRENT_BINARY_DIR}/${fpath}/${fname}.fl")
IF(NOT EXISTS "${fluid_name}")
SET(fluid_name "${fpath}/${fname}.fl")
IF(NOT EXISTS "${fluid_name}")
MESSAGE(SEND_ERROR "Cannot find Fluid source file: ${fpath}/${fname}.fl")
ENDIF(NOT EXISTS "${fluid_name}")
ENDIF(NOT EXISTS "${fluid_name}")
ENDIF(NOT EXISTS "${fluid_name}")
ENDIF(gen)
SET(cxx_name "${CMAKE_CURRENT_BINARY_DIR}/${fname}.cxx")
SET(h_name "${CMAKE_CURRENT_BINARY_DIR}/${fname}.h")
SET(${VARIABLE} "${${VARIABLE}};${cxx_name}")
ADD_CUSTOM_COMMAND(
OUTPUT ${cxx_name}
DEPENDS "${fluid_name}" "${FLUID_COMMAND}"
COMMAND ${FLUID_COMMAND}
ARGS -c ${fluid_name})
ADD_CUSTOM_COMMAND(
OUTPUT ${h_name}
DEPENDS "${fluid_name}" "${FLUID_COMMAND}"
COMMAND ${FLUID_COMMAND}
ARGS -c ${fluid_name})
ENDIF("${src}" MATCHES ".fl$")
ENDFOREACH(src)
ENDMACRO(FLTK_WRAP_FLUID VARIABLE)
# Make FLTK easier to use
INCLUDE_DIRECTORIES(${FLTK_INCLUDE_DIRS})
LINK_DIRECTORIES(${FLTK_LIBRARY_DIRS})
# Load the compiler settings used for FLTK.
IF(FLTK_BUILD_SETTINGS_FILE)
INCLUDE(CMakeImportBuildSettings)
CMAKE_IMPORT_BUILD_SETTINGS(${FLTK_BUILD_SETTINGS_FILE})
ENDIF(FLTK_BUILD_SETTINGS_FILE)
# Add compiler flags needed to use FLTK.
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLTK_REQUIRED_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLTK_REQUIRED_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLTK_REQUIRED_EXE_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${FLTK_REQUIRED_SHARED_LINKER_FLAGS}")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${FLTK_REQUIRED_MODULE_LINKER_FLAGS}")

View File

@@ -1,81 +0,0 @@
#ifdef HAVE_LIBZ
#include <zlib.h>
int main()
{
unsigned long compressedSize = 0;
unsigned char cd[100];
const unsigned char ud[100] = "";
unsigned long uncompressedSize = 0;
// Call zlib's compress function.
if(compress(cd, &compressedSize, ud, uncompressedSize) != Z_OK)
{
return 0;
}
return 1;
}
#endif
#ifdef HAVE_LIBJPEG
#include <stdio.h>
#include <jpeglib.h>
int main()
{
struct jpeg_decompress_struct cinfo;
jpeg_create_decompress(&cinfo);
jpeg_read_header(&cinfo, TRUE);
return 1;
}
#endif
#ifdef HAVE_LIBPNG
#include <png.h>
int main()
{
png_structp png_ptr = png_create_read_struct
(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
NULL, NULL);
png_infop info_ptr = png_create_info_struct(png_ptr);
png_set_sig_bytes(png_ptr, 8);
png_read_info(png_ptr, info_ptr);
return 0;
}
#endif
#ifdef HAVE_PNG_H
#include <png.h>
int main() { retunr 0;}
#endif
#ifdef HAVE_PNG_GET_VALID
#include <png.h>
int main()
{
png_structp png_ptr = png_create_read_struct
(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
NULL, NULL);
png_infop info_ptr = png_create_info_struct(png_ptr);
png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS);
return 0;
}
#endif
#ifdef HAVE_PNG_SET_TRNS_TO_ALPHA
#include <png.h>
int main()
{
png_structp png_ptr = png_create_read_struct
(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
NULL, NULL);
png_set_tRNS_to_alpha(png_ptr);
return 0;
}
#endif

View File

@@ -0,0 +1,8 @@
#
# automatically generated - do not edit
include_directories("@PREFIX_INCLUDE@")
if(FLTK_EXE_LINKER_FLAGS)
list(APPEND CMAKE_EXE_LINKER_FLAGS "${FLTK_EXE_LINKER_FLAGS}")
endif(FLTK_EXE_LINKER_FLAGS)

View File

@@ -0,0 +1,19 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR
"Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
exec_program("@CMAKE_COMMAND@"
ARGS "-E remove -f \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif(NOT "${rm_retval}" STREQUAL 0)
endforeach(file)

View File

@@ -0,0 +1,10 @@
#include <dirent.h>
int func (const char *d, dirent ***list, void *sort) {
int n = scandir(d, list, 0, (int(*)(const dirent **, const dirent **))sort);
}
int main() {
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -10,9 +10,11 @@ exceptions:
a specific platform do not constitute a modified or
derivative work.
The authors do request that such modifications be
contributed to the FLTK project - send all
contributions to "fltk-bugs@fltk.org".
The authors do request that such modifications be
contributed to the FLTK project - send all contributions
through the "Software Trouble Report" on the following page:
http://www.fltk.org/str.php
2. Widgets that are subclassed from FLTK widgets do not
constitute a derivative work.

View File

@@ -3,8 +3,10 @@ CREDITS - Fast Light Tool Kit (FLTK) Version 1.3.0
This file lists the people responsible for the toolkit you
are now using. If you've looking for your name in lights
but we've forgotten you here, please send an email to
"fltk-bugs@fltk.org" and we'll update this file accordingly.
but we've forgotten you here, please use the report on the
following page, and we'll update this file accordingly:
http://www.fltk.org/str.php
CORE DEVELOPERS
@@ -12,7 +14,7 @@ CORE DEVELOPERS
The following people do the day-to-day development of FLTK:
Fabien Costantini (fabien67@users.sf.net)
Craig P. Earls
Craig P. Earls
Curtis Edwards (trilec@users.sourceforge.net)
Gustavo Hime (hime@users.sourceforge.net)
Talbot Hughes
@@ -21,7 +23,7 @@ CORE DEVELOPERS
James Dean Palmer (jamespalmer@users.sourceforge.net)
Vincent Penne (vincentp@users.sourceforge.net)
Bill Spitzak (spitzak@users.sourceforge.net)
Michael Sweet (easysw@users.sourceforge.net)
Michael Sweet (easysw@users.sourceforge.net)
Carl Thompson (clip@users.sourceforge.net)
Nafees Bin Zafar (nafees@users.sourceforge.net)
@@ -39,6 +41,7 @@ OTHER CONTRIBUTORS
Yuri Fedorchenko
George Garvey
Duncan Gibson
Manolo Gouy
Mikael Hultgren
Stuart Levy
Howard Lightstone
@@ -47,9 +50,11 @@ OTHER CONTRIBUTORS
Alexander Rabi
James Roth
Albrecht Schlosser
Andrea Suatoni
Andrea Suatoni
Michael Surette
Paul Sydney
Aaron Ucko
Emanuele Vicentini
Josef Vitu
Jim Wilson
Ken Yarnall

View File

@@ -1,5 +1,5 @@
//
// "$Id: Enumerations.H 6902 2009-09-27 11:06:56Z matt $"
// "$Id: Enumerations.H 7476 2010-04-09 22:18:05Z matt $"
//
// Enumerations for the Fast Light Tool Kit (FLTK).
//
@@ -618,6 +618,27 @@ extern Fl_Labeltype FL_EXPORT fl_define_FL_EMBOSSED_LABEL();
* inside the widget.
*
* Flags can be or'd to achieve a combination of alignments.
*
* Outside alignments:
* \code
* TOP_LEFT TOP TOP_RIGHT
* LEFT_TOP+---------------------------------+RIGHT_TOP
* | |
* LEFT| |RIGHT
* | |
* LEFT_BOTTOM+---------------------------------+RIGHT_BOTTOM
* BOTTOM_RIGHT BOTTOM BOTTOM_LEFT
*
* Inside alignments:
* \code
* +---------------------------------+
* |TOP_LEFT TOP TOP_RIGHT|
* | |
* |LEFT RIGHT|
* | |
* |BOTTOM_RIGHT BOTTOM BOTTOM_LEFT|
* +---------------------------------+
* \endcode
* \see #FL_ALIGN_CENTER, etc.
*/
typedef unsigned Fl_Align;
@@ -637,24 +658,33 @@ const Fl_Align FL_ALIGN_RIGHT = (Fl_Align)8;
/** Draw the label inside of the widget. */
const Fl_Align FL_ALIGN_INSIDE = (Fl_Align)16;
/** If the label contains an image, draw the text on top of the image. */
const Fl_Align FL_ALIGN_TEXT_OVER_IMAGE = (Fl_Align)32;
const Fl_Align FL_ALIGN_TEXT_OVER_IMAGE = (Fl_Align)0x0020;
/** If the label contains an image, draw the text below the image. */
const Fl_Align FL_ALIGN_IMAGE_OVER_TEXT = (Fl_Align)0;
const Fl_Align FL_ALIGN_IMAGE_OVER_TEXT = (Fl_Align)0x0000;
/** All parts of the label that are lager than the widget will not be drawn . */
const Fl_Align FL_ALIGN_CLIP = (Fl_Align)64;
/** Wrap text that does not fit the width of the widget. */
const Fl_Align FL_ALIGN_WRAP = (Fl_Align)128;
/** If the label contains an image, draw the text to the right of the image. */
const Fl_Align FL_ALIGN_IMAGE_NEXT_TO_TEXT = (Fl_Align)0x0100;
/** If the label contains an image, draw the text to the left of the image. */
const Fl_Align FL_ALIGN_TEXT_NEXT_TO_IMAGE = (Fl_Align)0x0120;
/** If the label contains an image, draw the image or deimage in the backgroup. */
const Fl_Align FL_ALIGN_IMAGE_BACKDROP = (Fl_Align)0x0200;
const Fl_Align FL_ALIGN_TOP_LEFT = FL_ALIGN_TOP | FL_ALIGN_LEFT;
const Fl_Align FL_ALIGN_TOP_RIGHT = FL_ALIGN_TOP | FL_ALIGN_RIGHT;
const Fl_Align FL_ALIGN_BOTTOM_LEFT = FL_ALIGN_BOTTOM | FL_ALIGN_LEFT;
const Fl_Align FL_ALIGN_BOTTOM_RIGHT = FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT;
const Fl_Align FL_ALIGN_LEFT_TOP = FL_ALIGN_TOP_LEFT;
const Fl_Align FL_ALIGN_RIGHT_TOP = FL_ALIGN_TOP_RIGHT;
const Fl_Align FL_ALIGN_LEFT_BOTTOM = FL_ALIGN_BOTTOM_LEFT;
const Fl_Align FL_ALIGN_RIGHT_BOTTOM = FL_ALIGN_BOTTOM_RIGHT;
const Fl_Align FL_ALIGN_LEFT_TOP = 0x0007; // magic value
const Fl_Align FL_ALIGN_RIGHT_TOP = 0x000b; // magic value
const Fl_Align FL_ALIGN_LEFT_BOTTOM = 0x000d; // magic value
const Fl_Align FL_ALIGN_RIGHT_BOTTOM = 0x000e; // magic value
const Fl_Align FL_ALIGN_NOWRAP = (Fl_Align)0; // for back compatability
const Fl_Align FL_ALIGN_POSITION_MASK = 0x000f; // left, right, top, bottom
const Fl_Align FL_ALIGN_IMAGE_MASK = 0x0320; // l/r, t/b, backdrop
/*@}*/
/** \name Font Numbers */
/*@{*/
/** A font number is an index into the internal font table.
@@ -886,5 +916,5 @@ enum Fl_Damage {
#endif
//
// End of "$Id: Enumerations.H 6902 2009-09-27 11:06:56Z matt $".
// End of "$Id: Enumerations.H 7476 2010-04-09 22:18:05Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl.H 6903 2009-09-27 11:09:03Z matt $"
// "$Id: Fl.H 7334 2010-03-25 14:37:46Z AlbrechtS $"
//
// Main header file for the Fast Light Tool Kit (FLTK).
//
@@ -52,20 +52,59 @@ class Fl_Window;
class Fl_Image;
struct Fl_Label;
/** \defgroup callback_functions Callback function typedefs
\brief Typedefs for callback or handler functions passed as function parameters.
FLTK uses callback functions as parameters for some function calls, e.g. to
set up global event handlers (Fl::add_handler()), to add a timeout handler
(Fl::add_timeout()), and many more.
The typedefs defined in this group describe the function parameters used to set
up or clear the callback functions and should also be referenced to define the
callback function to handle such events in the user's code.
\see Fl::add_handler(), Fl::add_timeout(), Fl::repeat_timeout(),
Fl::remove_timeout() and others
@{ */
/** signature of some label drawing functions passed as parameters */
typedef void (Fl_Label_Draw_F)(const Fl_Label*, int,int,int,int, Fl_Align);
typedef void (Fl_Label_Draw_F)(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align);
/** signature of some label measurement functions passed as parameters */
typedef void (Fl_Label_Measure_F)(const Fl_Label*, int&, int&);
typedef void (Fl_Label_Measure_F)(const Fl_Label *label, int &width, int &height);
/** signature of some box drawing functions passed as parameters */
typedef void (Fl_Box_Draw_F)(int,int,int,int, Fl_Color);
typedef void (Fl_Box_Draw_F)(int x, int y, int w, int h, Fl_Color color);
/** signature of some timeout callback functions passed as parameters */
typedef void (*Fl_Timeout_Handler)(void*);
typedef void (*Fl_Timeout_Handler)(void *data);
/** signature of some wakeup callback functions passed as parameters */
typedef void (*Fl_Awake_Handler)(void*);
typedef void (*Fl_Awake_Handler)(void *data);
/** signature of add_idle callback functions passed as parameters */
typedef void (*Fl_Idle_Handler)(void *data);
/** signature of set_idle callback functions passed as parameters */
typedef void (*Fl_Old_Idle_Handler)();
/** signature of add_fd functions passed as parameters */
typedef void (*Fl_FD_Handler)(int fd, void *data);
/** signature of add_handler functions passed as parameters */
typedef int (*Fl_Event_Handler)(int event);
/** signature of set_abort functions passed as parameters */
typedef void (*Fl_Abort_Handler)(const char *format,...);
/** signature of set_atclose functions passed as parameters */
typedef void (*Fl_Atclose_Handler)(Fl_Window *window, void *data);
/** signature of args functions passed as parameters */
typedef int (*Fl_Args_Handler)(int argc, char **argv, int &i);
/** @} */ /* group callback_functions */
/**
The Fl is the FLTK global (static) containing
@@ -138,7 +177,7 @@ public:
// argument parsers:
static int arg(int, char**, int&);
static int args(int, char**, int&, int (*)(int,char**,int&) = 0);
static int args(int, char**, int&, Fl_Args_Handler ah = 0);
static void args(int, char**);
/**
Usage string displayed if Fl::args() detects an invalid argument.
@@ -232,7 +271,7 @@ public:
}
\endcode
*/
static void repeat_timeout(double t, Fl_Timeout_Handler,void* = 0); // platform dependent
static void repeat_timeout(double t, Fl_Timeout_Handler, void* = 0); // platform dependent
static int has_timeout(Fl_Timeout_Handler, void* = 0);
static void remove_timeout(Fl_Timeout_Handler, void* = 0);
static void add_check(Fl_Timeout_Handler, void* = 0);
@@ -257,17 +296,17 @@ public:
devices, pipes, sockets, etc.). Due to limitations in Microsoft Windows,
WIN32 applications can only monitor sockets.
*/
static void add_fd(int fd, int when, void (*cb)(int,void*),void* =0); // platform dependent
/** See void add_fd(int fd, int when, void (*cb)(int,void*),void* =0) */
static void add_fd(int fd, void (*cb)(int, void*), void* = 0); // platform dependent
static void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0); // platform dependent
/** See void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0) */
static void add_fd(int fd, Fl_FD_Handler cb, void* = 0); // platform dependent
/** Removes a file descriptor handler. */
static void remove_fd(int, int when); // platform dependent
/** Removes a file descriptor handler. */
static void remove_fd(int); // platform dependent
static void add_idle(void (*cb)(void*), void* data = 0);
static int has_idle(void (*cb)(void*), void* data = 0);
static void remove_idle(void (*cb)(void*), void* data = 0);
static void add_idle(Fl_Idle_Handler cb, void* data = 0);
static int has_idle(Fl_Idle_Handler cb, void* data = 0);
static void remove_idle(Fl_Idle_Handler cb, void* data = 0);
/** If true then flush() will do something. */
static int damage() {return damage_;}
static void redraw();
@@ -603,8 +642,8 @@ public:
/** Gets the current Fl::focus() widget. \sa Fl::focus(Fl_Widget*) */
static Fl_Widget* focus() {return focus_;}
static void focus(Fl_Widget*);
static void add_handler(int (*h)(int));
static void remove_handler(int (*h)(int));
static void add_handler(Fl_Event_Handler h);
static void remove_handler(Fl_Event_Handler h);
/** @} */
/** \defgroup fl_clipboard Selection & Clipboard functions
@@ -764,13 +803,13 @@ public:
/** \addtogroup fl_windows
@{ */
/** For back compatibility, sets the void Fl::fatal handler callback */
static void set_abort(void (*f)(const char*,...)) {fatal = f;}
static void set_abort(Fl_Abort_Handler f) {fatal = f;}
static void (*atclose)(Fl_Window*,void*);
static void default_atclose(Fl_Window*,void*);
/** For back compatibility, sets the Fl::atclose handler callback. You
can now simply change the callback for the window instead.
\see Fl_Window::callback(Fl_Callback*) */
static void set_atclose(void (*f)(Fl_Window*,void*)) {atclose = f;}
static void set_atclose(Fl_Atclose_Handler f) {atclose = f;}
/** @} */
/** \addtogroup fl_events
@@ -779,6 +818,8 @@ public:
static int event_shift() {return e_state&FL_SHIFT;}
/** Returns non-zero if the Control key is pressed. */
static int event_ctrl() {return e_state&FL_CTRL;}
/** Returns non-zero if the FL_COMMAND key is pressed, either FL_CTRL or on OSX FL_META. */
static int event_command() {return e_state&FL_COMMAND;}
/** Returns non-zero if the Alt key is pressed. */
static int event_alt() {return e_state&FL_ALT;}
/**
@@ -812,7 +853,7 @@ public:
\deprecated This method is obsolete - use the add_idle() method instead.
*/
static void set_idle(void (*cb)()) {idle = cb;}
static void set_idle(Fl_Old_Idle_Handler cb) {idle = cb;}
/** See Fl_Window* grab() */
static void grab(Fl_Window&win) {grab(&win);}
/** Releases the current grabbed window, equals grab(0).
@@ -1042,5 +1083,5 @@ public:
#endif // !Fl_H
//
// End of "$Id: Fl.H 6903 2009-09-27 11:09:03Z matt $".
// End of "$Id: Fl.H 7334 2010-03-25 14:37:46Z AlbrechtS $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Bitmap.H 6614 2009-01-01 16:11:32Z matt $"
// "$Id: Fl_Bitmap.H 7617 2010-05-27 17:20:18Z manolo $"
//
// Bitmap header file for the Fast Light Tool Kit (FLTK).
//
@@ -40,25 +40,34 @@ struct Fl_Menu_Item;
(bitmap) images. Images are drawn using the current color.
*/
class FL_EXPORT Fl_Bitmap : public Fl_Image {
public:
friend class Fl_Quartz_Graphics_Driver;
friend class Fl_GDI_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:
#if defined(__APPLE__) || defined(WIN32)
/** for internal use */
void *id;
void *id_;
#else
/** for internal use */
unsigned id;
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);}
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);}
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()); }
@@ -72,5 +81,5 @@ class FL_EXPORT Fl_Bitmap : public Fl_Image {
#endif
//
// End of "$Id: Fl_Bitmap.H 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: Fl_Bitmap.H 7617 2010-05-27 17:20:18Z manolo $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Button.H 6878 2009-09-17 22:12:24Z matt $"
// "$Id: Fl_Button.H 7499 2010-04-14 08:07:53Z manolo $"
//
// Button header file for the Fast Light Tool Kit (FLTK).
//
@@ -44,9 +44,7 @@
are set to zero.*/
#define FL_HIDDEN_BUTTON 3 ///< for Forms compatibility
#ifndef FL_DOXYGEN
extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
#endif
/**
\class Fl_Button
@@ -172,5 +170,5 @@ public:
#endif
//
// End of "$Id: Fl_Button.H 6878 2009-09-17 22:12:24Z matt $".
// End of "$Id: Fl_Button.H 7499 2010-04-14 08:07:53Z manolo $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Counter.H 6902 2009-09-27 11:06:56Z matt $"
// "$Id: Fl_Counter.H 6939 2009-11-17 14:45:36Z matt $"
//
// Counter header file for the Fast Light Tool Kit (FLTK).
//
@@ -98,7 +98,7 @@ public:
/**
Returns the increment for normal step buttons.
*/
double step() {return Fl_Valuator::step();}
double step() const {return Fl_Valuator::step();}
/** Gets the text font */
Fl_Font textfont() const {return textfont_;}
@@ -120,5 +120,5 @@ public:
#endif
//
// End of "$Id: Fl_Counter.H 6902 2009-09-27 11:06:56Z matt $".
// End of "$Id: Fl_Counter.H 6939 2009-11-17 14:45:36Z matt $".
//

View File

@@ -0,0 +1,386 @@
//
// "$Id: Fl_Device.H 7666 2010-07-04 17:19:38Z AlbrechtS $"
//
// Definition of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device
// for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// 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.
*/
#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>
#ifdef WIN32
#include <commdlg.h>
#elif defined(__APPLE__)
#else
#include <stdio.h>
#endif
class Fl_Graphics_Driver;
class Fl_Display_Device;
class Fl_Surface_Device;
/** \brief Points to the driver that currently receives all graphics requests */
FL_EXPORT extern Fl_Graphics_Driver *fl_graphics_driver;
/** \brief Points to the surface that currently receives all graphics requests */
FL_EXPORT extern Fl_Surface_Device *fl_surface;
/** \brief Points to the platform's display */
FL_EXPORT extern Fl_Display_Device *fl_display_device;
/**
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);
/**
\brief All graphical output devices and all graphics systems.
*/
class Fl_Device {
protected:
/** \brief The device type */
const char *type_;
/** \brief A string that identifies each subclass of Fl_Device.
*
Function type() applied to a device of this class returns this string.
*/
static const char *device_type;
public:
/**
@brief An RTTI emulation of device classes.
*
The type of an instance of an Fl_Device subclass can be checked with code such as:
\code
if ( instance->type() == Fl_Printer::device_type ) { ... }
\endcode
*/
inline const char *type() {return type_;};
};
/**
\brief A virtual class subclassed for each graphics driver FLTK uses.
*
The protected virtual methods of this class are those that a graphics driver should implement to
support all of FLTK drawing functions.
<br> The preferred FLTK API for drawing operations is the function collection of the
\ref fl_drawings and \ref fl_attributes modules.
<br> Alternatively, methods of the Fl_Graphics_Driver class can be called
using the global variable Fl_Graphics_Driver * \ref fl_graphics_driver that points at all time to
the single driver (an instance of an Fl_Graphics_Driver subclass) that's currently receiving graphics
requests. For example:
\code fl_graphics_driver->rect(x, y, w, h); \endcode
<br>Each protected method of the Fl_Graphics_Driver class has the same effect as the
function of the \ref fl_drawings and \ref fl_attributes modules which bears the same name
prefixed with fl_ and has the same parameter list.
*/
class Fl_Graphics_Driver : public Fl_Device {
protected:
/* ** \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 class Fl_PostScript_Graphics_Driver;
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_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);
/** \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);
/** \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_font(Fl_Font face, Fl_Fontsize size). */
virtual void font(Fl_Font face, Fl_Fontsize size);
/** \brief see fl_color(Fl_Color c). */
virtual void color(Fl_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();
// 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) {};
public:
static const char *device_type;
/** \brief The destructor */
virtual ~Fl_Graphics_Driver() {};
};
#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_Quartz_Graphics_Driver : public Fl_Graphics_Driver {
public:
Fl_Quartz_Graphics_Driver() { type_ = device_type; };
static const char *device_type;
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);
};
#endif
#if defined(WIN32) || defined(FL_DOXYGEN)
/**
\brief The MSWindows-specific graphics class.
*
This class is implemented only on the MSWindows platform.
*/
class Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver {
public:
Fl_GDI_Graphics_Driver() { type_ = device_type; };
static const char *device_type;
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);
};
#endif
#if !(defined(__APPLE__) || defined(WIN32))
/**
\brief The Xlib-specific graphics class.
*
This class is implemented only on the Xlib platform.
*/
class Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver {
public:
Fl_Xlib_Graphics_Driver() { type_ = device_type; };
static const char *device_type;
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);
};
#endif
/**
\brief A surface that's susceptible to receive graphical output.
*/
class Fl_Surface_Device : public Fl_Device {
/** \brief The graphics driver in use by this surface. */
Fl_Graphics_Driver *_driver;
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 *device_type;
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; };
/** \brief the surface that currently receives graphics output */
static Fl_Surface_Device *surface() {return fl_surface; };
/** \brief The destructor. */
virtual ~Fl_Surface_Device() {}
};
/**
\brief A display to which the computer can draw.
*/
class Fl_Display_Device : public Fl_Surface_Device {
public:
static const char *device_type;
/** \brief A constructor that sets the graphics driver used by the display */
Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device( graphics_driver) { type_ = device_type; };
/**
@brief Returns the platform's display device.
*/
static Fl_Display_Device *display_device() { return fl_display_device; };
};
#endif // Fl_Device_H
//
// End of "$Id: Fl_Device.H 7666 2010-07-04 17:19:38Z AlbrechtS $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_File_Chooser.H 6678 2009-03-13 23:36:09Z AlbrechtS $"
// "$Id: Fl_File_Chooser.H 7007 2010-01-14 23:08:06Z greg.ercolano $"
//
// Fl_File_Chooser dialog for the Fast Light Tool Kit (FLTK).
//
@@ -222,6 +222,7 @@ private:
Fl_Widget* ext_group;
public:
Fl_Widget* add_extra(Fl_Widget* gr);
Fl_File_Browser *browser(void) {return fileList; };
};
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);
@@ -230,5 +231,5 @@ FL_EXPORT void fl_file_chooser_ok_label(const char*l);
#endif
//
// End of "$Id: Fl_File_Chooser.H 6678 2009-03-13 23:36:09Z AlbrechtS $".
// End of "$Id: Fl_File_Chooser.H 7007 2010-01-14 23:08:06Z greg.ercolano $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Group.H 6907 2009-09-28 14:34:52Z matt $"
// "$Id: Fl_Group.H 7280 2010-03-16 22:51:31Z matt $"
//
// Group header file for the Fast Light Tool Kit (FLTK).
//
@@ -176,6 +176,14 @@ public:
*/
unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
/** Returns an Fl_Group pointer if this widget is an Fl_Group.
\retval NULL if this widget is not derived from Fl_Group.
\note This method is provided to avoid dynamic_cast.
\todo More documentation ...
*/
virtual Fl_Group* as_group() { return this; }
// back compatibility functions:
/**
@@ -222,5 +230,5 @@ public:
#endif
//
// End of "$Id: Fl_Group.H 6907 2009-09-28 14:34:52Z matt $".
// End of "$Id: Fl_Group.H 7280 2010-03-16 22:51:31Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Help_View.H 6743 2009-04-07 17:33:22Z AlbrechtS $"
// "$Id: Fl_Help_View.H 7139 2010-02-23 15:55:22Z greg.ercolano $"
//
// Help Viewer widget definitions.
//
@@ -147,6 +147,66 @@ struct Fl_Help_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 premil 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
{
@@ -334,5 +394,5 @@ public:
#endif // !Fl_Help_View_H
//
// End of "$Id: Fl_Help_View.H 6743 2009-04-07 17:33:22Z AlbrechtS $".
// End of "$Id: Fl_Help_View.H 7139 2010-02-23 15:55:22Z greg.ercolano $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Image.H 6614 2009-01-01 16:11:32Z matt $"
// "$Id: Fl_Image.H 7617 2010-05-27 17:20:18Z manolo $"
//
// Image header file for the Fast Light Tool Kit (FLTK).
//
@@ -188,21 +188,29 @@ class FL_EXPORT Fl_Image {
&lt;FL/Fl_RGB_Image.H&gt; should be included.
*/
class FL_EXPORT Fl_RGB_Image : public Fl_Image {
public:
friend class Fl_Quartz_Graphics_Driver;
friend class Fl_GDI_Graphics_Driver;
friend class Fl_Xlib_Graphics_Driver;
public:
const uchar *array;
int alloc_array; // Non-zero if array was allocated
private:
#if defined(__APPLE__) || defined(WIN32)
void *id; // for internal use
void *mask; // for internal use (mask bitmap)
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)
unsigned id_; // for internal use
unsigned mask_; // for internal use (mask bitmap)
#endif // __APPLE__ || WIN32
public:
/** The constructor creates a new image from the specified data. */
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
Fl_Image(W,H,D), array(bits), alloc_array(0), id(0), mask(0) {data((const char **)&array, 1); ld(LD);}
Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
virtual ~Fl_RGB_Image();
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return copy(w(), h()); }
@@ -218,5 +226,5 @@ class FL_EXPORT Fl_RGB_Image : public Fl_Image {
#endif // !Fl_Image_H
//
// End of "$Id: Fl_Image.H 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: Fl_Image.H 7617 2010-05-27 17:20:18Z manolo $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Input_.H 6902 2009-09-27 11:06:56Z matt $"
// "$Id: Fl_Input_.H 7672 2010-07-10 09:44:45Z matt $"
//
// Input base class header file for the Fast Light Tool Kit (FLTK).
//
@@ -151,7 +151,7 @@ class FL_EXPORT Fl_Input_ : public Fl_Widget {
/** \internal Horizontal cursor position in pixels while movin up or down. */
static double up_down_pos;
/** \internal Flag to remeber last cursor move. */
/** \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. */
@@ -451,5 +451,5 @@ public:
#endif
//
// End of "$Id: Fl_Input_.H 6902 2009-09-27 11:06:56Z matt $".
// End of "$Id: Fl_Input_.H 7672 2010-07-10 09:44:45Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Input_Choice.H 6614 2009-01-01 16:11:32Z matt $"
// "$Id: Fl_Input_Choice.H 7115 2010-02-20 17:40:07Z AlbrechtS $"
//
// An input/chooser widget.
// ______________ ____
@@ -76,6 +76,7 @@ class Fl_Input_Choice : public 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()))
@@ -92,6 +93,8 @@ class Fl_Input_Choice : public Fl_Group {
if (o->when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE))
o->do_callback();
}
if (wp.deleted()) return;
if (o->callback() != default_callback)
{
@@ -102,6 +105,7 @@ class Fl_Input_Choice : public 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))
@@ -111,6 +115,8 @@ class Fl_Input_Choice : public Fl_Group {
if (o->when() & FL_WHEN_NOT_CHANGED)
o->do_callback();
}
if (wp.deleted()) return;
if (o->callback() != default_callback)
o->Fl_Widget::clear_changed();
@@ -212,5 +218,5 @@ public:
#endif // !Fl_Input_Choice_H
//
// End of "$Id: Fl_Input_Choice.H 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: Fl_Input_Choice.H 7115 2010-02-20 17:40:07Z AlbrechtS $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu_.H 6902 2009-09-27 11:06:56Z matt $"
// "$Id: Fl_Menu_.H 7517 2010-04-16 17:55:45Z greg.ercolano $"
//
// Menu base class header file for the Fast Light Tool Kit (FLTK).
//
@@ -52,7 +52,7 @@ class FL_EXPORT Fl_Menu_ : public Fl_Widget {
protected:
uchar alloc;
uchar alloc; // flag indicates if menu_ is a dynamic copy (=1) or not (=0)
uchar down_box_;
Fl_Font textfont_;
Fl_Fontsize textsize_;
@@ -65,6 +65,10 @@ public:
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;
const Fl_Menu_Item* test_shortcut() {return picked(menu()->test_shortcut());}
void global();
@@ -76,14 +80,21 @@ public:
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 int Fl_Menu_::add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0)*/
/** 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);}
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 i to n. */
@@ -142,5 +153,5 @@ public:
#endif
//
// End of "$Id: Fl_Menu_.H 6902 2009-09-27 11:06:56Z matt $".
// End of "$Id: Fl_Menu_.H 7517 2010-04-16 17:55:45Z greg.ercolano $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu_Item.H 6902 2009-09-27 11:06:56Z matt $"
// "$Id: Fl_Menu_Item.H 7517 2010-04-16 17:55:45Z greg.ercolano $"
//
// Menu item header file for the Fast Light Tool Kit (FLTK).
//
@@ -386,6 +386,7 @@ struct FL_EXPORT Fl_Menu_Item {
/** 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) */
@@ -414,5 +415,5 @@ enum { // back-compatibility enum:
#endif
//
// End of "$Id: Fl_Menu_Item.H 6902 2009-09-27 11:06:56Z matt $".
// End of "$Id: Fl_Menu_Item.H 7517 2010-04-16 17:55:45Z greg.ercolano $".
//

View File

@@ -0,0 +1,51 @@
//
// "$Id: Fl_Native_File_Chooser.H 7003 2010-01-14 20:47:59Z greg.ercolano $"
//
// FLTK native OS file chooser widget
//
// Copyright 1998-2009 by Bill Spitzak and others.
// Copyright 2004 Greg Ercolano.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#ifndef FL_NATIVE_FILE_CHOOSER_H
#define FL_NATIVE_FILE_CHOOSER_H
// Use Windows' chooser
#ifdef WIN32
#include <FL/Fl_Native_File_Chooser_WIN32.H>
#endif
// Use Apple's chooser
#ifdef __APPLE__
#include <FL/Fl_Native_File_Chooser_MAC.H>
#endif
// All else falls back to FLTK's own chooser
#if ! defined(__APPLE__) && !defined(WIN32)
#include <FL/Fl_Native_File_Chooser_FLTK.H>
#endif
#endif /*FL_NATIVE_FILE_CHOOSER_H*/
//
// End of "$Id: Fl_Native_File_Chooser.H 7003 2010-01-14 20:47:59Z greg.ercolano $".
//

View File

@@ -0,0 +1,142 @@
//
// "$Id: Fl_Native_File_Chooser_FLTK.H 7007 2010-01-14 23:08:06Z greg.ercolano $"
//
// FLTK native OS file chooser widget
//
// Copyright 1998-2009 by Bill Spitzak and others.
// Copyright 2005 by Nathan Vander Wilt.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
/* \file
Fl_Native_File_Chooser widget. */
#include <FL/Fl_File_Chooser.H>
#include <unistd.h> // _POSIX_NAME_MAX
/**
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).
<P>
In cases where there is no native file browser, FLTK's own file browser
is used instead.
<P>
\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");
// 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
<P>
<B>Platform Specific Caveats</B>
<P>
- Under X windows, 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.
- Some operating systems support certain OS specific options; see
Fl_Native_File_Chooser::options() for a list.
*/
class 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 (if supported)
NEW_FOLDER = 0x0002, ///< Show 'New Folder' icon (if supported)
PREVIEW = 0x0004, ///< enable preview mode
};
private:
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
char *_old_dir;
Fl_File_Chooser *_file_chooser;
// added by MG
Fl_File_Browser *my_fileList;
Fl_Check_Button *show_hidden;
int prev_filtervalue;
static void show_hidden_cb(Fl_Check_Button *o, void *data);
static void remove_hidden_files(Fl_File_Browser *my_fileList);
// Private methods
void errmsg(const char *msg);
int type_fl_file(int);
void parse_filter();
void keeplocation();
int exist_dialog();
public:
Fl_Native_File_Chooser(int val=BROWSE_FILE);
~Fl_Native_File_Chooser();
// Public methods
void type(int);
int type() const;
void options(int);
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 *);
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;
int show();
};
//
// End of "$Id: Fl_Native_File_Chooser_FLTK.H 7007 2010-01-14 23:08:06Z greg.ercolano $".
//

View File

@@ -0,0 +1,122 @@
//
// "$Id: Fl_Native_File_Chooser_MAC.H 7354 2010-03-29 11:07:29Z matt $"
//
// FLTK native OS file chooser widget
//
// Copyright 1998-2009 by Bill Spitzak and others.
// Copyright 2004 Greg Ercolano.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#ifndef FL_DOXYGEN // PREVENT DOXYGEN'S USE OF THIS FILE
// OSX-SPECIFIC NATIVE BROWSER
#include <Carbon/Carbon.h>
#include <config.h>
#undef check // necessary for use of Fl::check()
#include <FL/filename.H>
#define MAXFILTERS 80
class Fl_Native_File_Chooser {
public:
enum Type {
BROWSE_FILE = 0,
BROWSE_DIRECTORY,
BROWSE_MULTI_FILE,
BROWSE_MULTI_DIRECTORY,
BROWSE_SAVE_FILE,
BROWSE_SAVE_DIRECTORY
};
enum Option {
NO_OPTIONS = 0x0000, // no options enabled
SAVEAS_CONFIRM = 0x0001, // Show native 'Save As' overwrite confirm dialog (if supported)
NEW_FOLDER = 0x0002, // Show 'New Folder' icon (if supported)
PREVIEW = 0x0004, // enable preview mode
};
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();
public:
Fl_Native_File_Chooser(int val = BROWSE_FILE);
~Fl_Native_File_Chooser();
// Public methods
void type(int);
int type() const;
void options(int);
int options() const;
int count() const;
const char *filename() const;
const char *filename(int i) const;
void directory(const char *);
const char *directory() const;
void title(const char *);
const char *title() const;
const char *filter() const;
void filter(const char *);
void filter_value(int i) { _filt_value = i; }
int filter_value() { return(_filt_value); }
int filters() { return(_filt_total); }
void preset_file(const char *);
const char *preset_file();
const char *errmsg() const;
int show();
};
#endif /*!FL_DOXYGEN*/
//
// End of "$Id: Fl_Native_File_Chooser_MAC.H 7354 2010-03-29 11:07:29Z matt $".
//

View File

@@ -0,0 +1,120 @@
//
// "$Id: Fl_Native_File_Chooser_WIN32.H 7003 2010-01-14 20:47:59Z greg.ercolano $"
//
// FLTK native OS file chooser widget
//
// Copyright 1998-2005 by Bill Spitzak and others.
// Copyright 2004 by Greg Ercolano.
// April 2005 - API changes, improved filter processing by Nathan Vander Wilt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to:
//
// http://www.fltk.org/str.php
//
#ifndef FL_DOXYGEN // PREVENT DOXYGEN'S USE OF THIS FILE
// #define _WIN32_WINNT 0x0501 // needed for OPENFILENAME's 'FlagsEx'
#include <stdio.h>
#include <stdlib.h> // malloc
#include <windows.h>
#include <commdlg.h> // OPENFILENAME, GetOpenFileName()
#include <shlobj.h> // BROWSEINFO, SHBrowseForFolder()
class Fl_Native_File_Chooser {
public:
enum Type {
BROWSE_FILE = 0,
BROWSE_DIRECTORY,
BROWSE_MULTI_FILE,
BROWSE_MULTI_DIRECTORY,
BROWSE_SAVE_FILE,
BROWSE_SAVE_DIRECTORY
};
enum Option {
NO_OPTIONS = 0x0000, // no options enabled
SAVEAS_CONFIRM = 0x0001, // Show native 'Save As' overwrite confirm dialog (if supported)
NEW_FOLDER = 0x0002, // Show 'New Folder' icon (if supported)
PREVIEW = 0x0004, // enable preview mode
};
private:
int _btype; // kind-of browser to show()
int _options; // general options
OPENFILENAMEW _ofn; // GetOpenFileName() & GetSaveFileName() struct
BROWSEINFO _binf; // SHBrowseForFolder() struct
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 FreePIDL(ITEMIDLIST *pidl);
void ClearOFN();
void ClearBINF();
void Win2Unix(char *s);
void Unix2Win(char *s);
int showfile();
static int CALLBACK Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data);
int showdir();
void parse_filter(const char *);
void clear_filters();
void add_filter(const char *, const char *);
public:
Fl_Native_File_Chooser(int val = BROWSE_FILE);
~Fl_Native_File_Chooser();
// Public methods
void type(int val);
int type() const;
void options(int);
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 *val);
const char *title() const;
const char *filter() const;
void filter(const char *val);
int filters() const { return _nfilters; }
void filter_value(int i);
int filter_value() const;
void preset_file(const char *);
const char *preset_file() const;
const char *errmsg() const;
int show();
};
#endif /*!FL_DOXYGEN*/
//
// End of "$Id: Fl_Native_File_Chooser_WIN32.H 7003 2010-01-14 20:47:59Z greg.ercolano $".
//

View File

@@ -0,0 +1,92 @@
//
// "$Id: Fl_Paged_Device.H 7622 2010-05-27 17:50:51Z manolo $"
//
// Printing support for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// 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>
/**
\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_Paged_Device : public Fl_Surface_Device {
private:
#ifdef __APPLE__
struct chain_elt {
Fl_Image *image;
const uchar *data;
struct chain_elt *next;
};
void add_image(Fl_Image *image, const uchar *data); // adds an image to the page image list
#endif
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 chained list of Fl_Image's used in this page */
struct chain_elt *image_list_;
#ifdef __APPLE__
/** \brief deletes the page image list */
void delete_image_list();
#endif
/** \brief The constructor */
Fl_Paged_Device() : Fl_Surface_Device(NULL) {type_ = device_type;};
/** \brief The destructor */
virtual ~Fl_Paged_Device() {};
public:
static const char *device_type;
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);
void origin(int *x, int *y);
virtual void scale(float scale_x, float scale_y);
virtual void rotate(float angle);
virtual void translate(int x, int y);
virtual void untranslate(void);
void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0);
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: Fl_Paged_Device.H 7622 2010-05-27 17:50:51Z manolo $"
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Pixmap.H 6614 2009-01-01 16:11:32Z matt $"
// "$Id: Fl_Pixmap.H 7617 2010-05-27 17:20:18Z manolo $"
//
// Pixmap header file for the Fast Light Tool Kit (FLTK).
//
@@ -45,6 +45,9 @@ struct Fl_Menu_Item;
(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_Xlib_Graphics_Driver;
void copy_data();
void delete_data();
void set_data(const char * const *p);
@@ -56,22 +59,27 @@ class FL_EXPORT Fl_Pixmap : public Fl_Image {
public:
int alloc_data; // Non-zero if data was allocated
private:
#if defined(__APPLE__) || defined(WIN32)
void *id; // for internal use
void *mask; // for internal use (mask bitmap)
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)
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();}
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();}
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();}
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();}
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()); }
@@ -87,5 +95,5 @@ class FL_EXPORT Fl_Pixmap : public Fl_Image {
#endif
//
// End of "$Id: Fl_Pixmap.H 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: Fl_Pixmap.H 7617 2010-05-27 17:20:18Z manolo $".
//

View File

@@ -0,0 +1,106 @@
//
// "$Id: Fl_Plugin.H 6995 2010-01-12 08:48:55Z matt $"
//
// A Plugin system for FLTK, implemented in Fl_Preferences.cxx.
//
// Copyright 2002-2010 by Matthias Melcher.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
/* \file
Fl_Plugin class . */
#ifndef Fl_Plugin_H
# define Fl_Plugin_H
# include "Fl_Preferences.H"
/**
\brief Fl_Plugin allows link-time and run-time integration of binary modules.
Fl_Plugin and Fl_Plugin_Manager provide a small and simple solution for
linking C++ classes at run-time, or optionally linking modules at compile
time without the need to change the main application.
Fl_Plugin_Manager uses static initialisation to create the plugin interface
early during startup. Plugins are stored in a temporary database, organized
in classes.
Plugins should derive a new class from Fl_Plugin as a base:
\code
class My_Plugin : public Fl_Plugin {
public:
My_Plugin() : Fl_Plugin("effects", "blur") { }
void do_something(...);
};
My_Plugin blur_plugin();
\endcode
Plugins can be put into modules and either linked befor distribution, or loaded
from dynamically linkable files. An Fl_Plugin_Manager is used to list and
access all currently loaded plugins.
\code
Fl_Plugin_Manager mgr("effects");
int i, n = mgr.plugins();
for (i=0; i<n; i++) {
My_Plugin *pin = (My_Plugin*)mgr.plugin(i);
pin->do_something();
}
\endcode
*/
class FL_EXPORT Fl_Plugin
{
Fl_Preferences::ID id;
public:
Fl_Plugin(const char *klass, const char *name);
virtual ~Fl_Plugin();
};
/**
\brief Fl_Plugin_Manager manages link-time and run-time plugin binaries.
\see Fl_Plugin
*/
class FL_EXPORT Fl_Plugin_Manager : public Fl_Preferences
{
public:
Fl_Plugin_Manager(const char *klass);
~Fl_Plugin_Manager();
/** \brief Return the number of plugins in the klass.
*/
int plugins() { return groups(); }
Fl_Plugin *plugin(int index);
Fl_Plugin *plugin(const char *name);
Fl_Preferences::ID addPlugin(const char *name, Fl_Plugin *plugin);
static void removePlugin(Fl_Preferences::ID id);
static int load(const char *filename);
static int loadAll(const char *filepath, const char *pattern=0);
};
#endif // !Fl_Preferences_H
//
// End of "$Id: Fl_Preferences.H 6995 2010-01-12 08:48:55Z matt $".
//

View File

@@ -0,0 +1,293 @@
//
// "$Id: Fl_PostScript.H 7622 2010-05-27 17:50:51Z manolo $"
//
// Support for graphics output to PostScript file for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
/** \file Fl_PostScript.H
\brief declaration of classes Fl_PostScript_Graphics_Driver, Fl_PostScript_File_Device.
*/
#ifndef Fl_PostScript_H
#define Fl_PostScript_H
#include <FL/Fl_Paged_Device.H>
#include <FL/fl_draw.H>
#define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */
/**
\brief PostScript graphical backend.
*
PostScript text output is presently implemented only for the latin character set.
FLTK's standard fonts are output using PostScript's standard fonts: Helvetica, Courier,
Times (and their bold, oblique, italic variants), Symbol, ZapfDingbats.
*/
class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
public:
static const char *device_type;
/**
\brief Possible page formats.
*/
enum Page_Format {
A0 = 0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
A8,
A9,
B0,
B1,
B2,
B3,
B4,
B5,
B6,
B7,
B8,
B9,
B10,
C5E,
DLE,
EXECUTIVE,
FOLIO,
LEDGER,
LEGAL,
LETTER,
TABLOID,
ENVELOPE,
MEDIA = 0x1000
};
/**
\brief Possible page layouts.
*/
enum Page_Layout {PORTRAIT = 0, LANDSCAPE = 0x100, REVERSED = 0x200, ORIENTATION = 0x300};
#ifndef FL_DOXYGEN
public:
enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
typedef struct page_format {
int width;
int height;
const char *name;
} page_format;
class Clip {
public:
int x, y, w, h;
Clip *prev;
};
Clip * clip_;
int lang_level_;
int font_;
int size_;
Fl_Color color_;
int gap_;
int pages_;
double width_;
double height_;
int shape_;
int linewidth_;// need for clipping, lang level 1-2
int linestyle_;//
int interpolate_; //interpolation of images
unsigned char cr_,cg_,cb_;
char linedash_[256];//should be enough
void concat(); // transform ror scalable dradings...
void reconcat(); //invert
void recover(); //recovers the state after grestore (such as line styles...)
void reset();
uchar * mask;
int mx; // width of mask;
int my; // mask lines
//Fl_Color bg_;
int (*close_cmd_)(FILE *);
int page_policy_;
int nPages;
int orientation_;
float scale_x;
float scale_y;
float angle;
int left_margin;
int top_margin;
FILE *output;
double pw_, ph_;
static const page_format page_formats[NO_PAGE_FORMATS];
uchar bg_r, bg_g, bg_b;
int start_postscript (int pagecount, enum Page_Format format, enum Page_Layout layout);
/* int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
*/
void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); };
void draw(int angle, const char *str, int n, int x, int y);
void transformed_draw(const char* s, int n, double x, double y); //precise text placing
void transformed_draw(const char* s, double x, double y);
int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
void draw_scaled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
void draw_scaled_image_mono(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
void draw_scaled_image(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D);
void draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D);
enum Page_Format page_format_;
char *ps_filename_;
// implementation of drawing methods
void color(Fl_Color c);
//void bg_color(Fl_Color bg);
void color(uchar r, uchar g, uchar b);
Fl_Color color(){return color_;};
void push_clip(int x, int y, int w, int h);
int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
int not_clipped(int x, int y, int w, int h);
void push_no_clip();
void pop_clip();
void line_style(int style, int width=0, char* dashes=0);
void rect(int x, int y, int w, int h);
void rectf(int x, int y, int w, int h);
void xyline(int x, int y, int x1);
void xyline(int x, int y, int x1, int y2);
void xyline(int x, int y, int x1, int y2, int x3);
void yxline(int x, int y, int y1);
void yxline(int x, int y, int y1, int x2);
void yxline(int x, int y, int y1, int x2, int y3);
void line(int x1, int y1, int x2, int y2);
void line(int x1, int y1, int x2, int y2, int x3, int y3);
void loop(int x0, int y0, int x1, int y1, int x2, int y2);
void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
void point(int x, int y);
void begin_points();
void begin_line();
void begin_loop();
void begin_polygon();
void vertex(double x, double y);
void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3);
void circle(double x, double y, double r);
void arc(double x, double y, double r, double start, double a);
void arc(int x, int y, int w, int h, double a1, double a2);
void pie(int x, int y, int w, int h, double a1, double a2);
void end_points();
void end_line();
void end_loop();
void end_polygon();
void begin_complex_polygon(){begin_polygon();};
void gap(){gap_=1;};
void end_complex_polygon(){end_polygon();};
void transformed_vertex(double x, double y);
void font(int face, int size);
int font(){return font_;};
int size(){return size_;};
double width(unsigned c);
double width(const char* s, int n);
int descent();
int height();
void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0){draw_scaled_image(d,x,y,w,h,w,h,delta,ldelta);};
void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0){draw_scaled_image_mono(d,x,y,w,h,w,h,delta,ld);};
void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3){draw_scaled_image(call,data, x, y, w, h, w, h, delta);};
void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1){draw_scaled_image_mono(call, data, x, y, w, h, w, h, delta);};
void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
public:
void page_policy(int p);
int page_policy(){return page_policy_;};
void close_command( int (*cmd)(FILE *)){close_cmd_=cmd;};
FILE * file() {return output;};
//void orientation (int o);
//Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor
//Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor
void interpolate(int i){interpolate_=i;};
int interpolate(){return interpolate_;}
void page(double pw, double ph, int media = 0);
void page(int format);
void place(double x, double y, double tx, double ty, double scale = 1);
#endif // FL_DOXYGEN
Fl_PostScript_Graphics_Driver();
~Fl_PostScript_Graphics_Driver();
};
/**
\brief To send graphical output to a PostScript file.
*/
class Fl_PostScript_File_Device : public Fl_Paged_Device {
#ifdef __APPLE__
CGContextRef gc;
#endif
protected:
Fl_PostScript_Graphics_Driver *driver();
public:
static const char *device_type;
Fl_PostScript_File_Device();
~Fl_PostScript_File_Device();
int start_job(int pagecount, enum Fl_PostScript_Graphics_Driver::Page_Format format = Fl_PostScript_Graphics_Driver::A4,
enum Fl_PostScript_Graphics_Driver::Page_Layout layout = Fl_PostScript_Graphics_Driver::PORTRAIT);
int start_job(FILE *ps_output, int pagecount, enum Fl_PostScript_Graphics_Driver::Page_Format format = Fl_PostScript_Graphics_Driver::A4,
enum Fl_PostScript_Graphics_Driver::Page_Layout layout = Fl_PostScript_Graphics_Driver::PORTRAIT);
int start_page (void);
int printable_rect(int *w, int *h);
void margins(int *left, int *top, int *right, int *bottom);
void origin(int x, int y);
void scale (float scale_x, float scale_y);
void rotate(float angle);
void translate(int x, int y);
void untranslate(void);
int end_page (void);
void end_job(void);
#ifdef __APPLE__
void set_current() { fl_gc = gc; Fl_Paged_Device::set_current(); }
#endif
static const char *file_chooser_title;
};
#endif // Fl_PostScript_H
//
// End of "$Id: Fl_PostScript.H 7622 2010-05-27 17:50:51Z manolo $"
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Preferences.H 6770 2009-04-18 18:52:59Z matt $"
// "$Id: Fl_Preferences.H 7672 2010-07-10 09:44:45Z matt $"
//
// Preferences .
//
@@ -57,11 +57,11 @@
yet exist.
Entries can be of any length. However, the size of each
preferences file should be kept under 100k for performance
preferences file should be kept small for performance
reasons. One application can have multiple preferences files.
Extensive binary data however should be stored in separate
files: see getUserdataPath().
\note Starting with FLTK 1.3, preference databases are expected to
be in utf8 encoding. Previous databases were stored in the
current chracter set or code page which renders them incompatible
@@ -79,22 +79,57 @@ public:
SYSTEM=0, ///< Preferences are used system-wide
USER ///< Preferences apply only to the current user
};
/**
Every Fl_Preferences-Group has a uniqe ID.
ID's can be retrieved from an Fl_Preferences-Group and can then be used
to create more Fl_Preference references to the same data set, as long as the
database remains open.
*/
typedef void *ID;
static const char *newUUID();
Fl_Preferences( Root root, const char *vendor, const char *application );
Fl_Preferences( const char *path, const char *vendor, const char *application );
Fl_Preferences( Fl_Preferences &parent, const char *group );
Fl_Preferences( Fl_Preferences*, const char *group );
Fl_Preferences( Fl_Preferences *parent, const char *group );
Fl_Preferences( Fl_Preferences &parent, int groupIndex );
Fl_Preferences( Fl_Preferences *parent, int groupIndex );
Fl_Preferences(const Fl_Preferences&);
Fl_Preferences( ID id );
~Fl_Preferences();
/** Return an ID that can later be reused to open more references to this dataset.
*/
ID id() { return (ID)node; }
/** Remove the group with this ID from a database.
*/
static char remove(ID id_) { return ((Node*)id_)->remove(); }
/** Return the name of this entry.
*/
const char *name() { return node->name(); }
/** Return the the full path to this entry.
*/
const char *path() { return node->path(); }
int groups();
const char *group( int num_group );
char groupExists( const char *key );
char deleteGroup( const char *group );
char deleteAllGroups();
int entries();
const char *entry( int index );
char entryExists( const char *key );
char deleteEntry( const char *entry );
char deleteAllEntries();
char clear();
char set( const char *entry, int value );
char set( const char *entry, float value );
@@ -120,6 +155,8 @@ public:
// char export( const char *filename, Type fileFormat );
// char import( const char *filename );
// char copyTo(class Fl_Tree*); // deprecated, use Fl_Tree::load(Fl_Preferences&)
/**
'Name' provides a simple method to create numerical or more complex
@@ -157,30 +194,54 @@ public:
private:
// make the following functions unavailable
Fl_Preferences();
Fl_Preferences(const Fl_Preferences&);
Fl_Preferences() : node(0), rootNode(0) { }
Fl_Preferences &operator=(const Fl_Preferences&);
static char nameBuffer[128];
static char uuidBuffer[40];
static Fl_Preferences *runtimePrefs;
class RootNode;
class FL_EXPORT Node // a node contains a list to all its entries
{ // and all means to manage the tree structure
Node *child_, *next_, *parent_;
Node *child_, *next_;
union { // these two are mutually exclusive
Node *parent_; // top_ bit clear
RootNode *root_; // top_ bit set
};
char *path_;
char dirty_;
Entry *entry_;
int nEntry_, NEntry_;
unsigned char dirty_:1;
unsigned char top_:1;
unsigned char indexed_:1;
// indexing routines
Node **index_;
int nIndex_, NIndex_;
void createIndex();
void updateIndex();
void deleteIndex();
public:
static int lastEntrySet;
public:
Node( const char *path );
~Node();
// node methods
int write( FILE *f );
const char *name();
const char *path() { return path_; }
Node *find( const char *path );
Node *search( const char *path, int offset=0 );
Node *childNode( int ix );
Node *addChild( const char *path );
void setParent( Node *parent );
Node *parent() { return parent_; }
Node *parent() { return top_?0L:parent_; }
void setRoot(RootNode *r) { root_ = r; top_ = 1; }
RootNode *findRoot();
char remove();
char dirty();
void deleteAllChildren();
// entry methods
int nChildren();
const char *child( int ix );
@@ -190,10 +251,9 @@ private:
const char *get( const char *name );
int getEntry( const char *name );
char deleteEntry( const char *name );
// public values
Entry *entry;
int nEntry, NEntry;
static int lastEntrySet;
void deleteAllEntries();
int nEntry() { return nEntry_; }
Entry &entry(int i) { return entry_[i]; }
};
friend class Node;
@@ -205,6 +265,7 @@ private:
public:
RootNode( Fl_Preferences *, Root root, const char *vendor, const char *application );
RootNode( Fl_Preferences *, const char *path, const char *vendor, const char *application );
RootNode( Fl_Preferences * );
~RootNode();
int read();
int write();
@@ -212,14 +273,15 @@ private:
};
friend class RootNode;
protected:
Node *node;
RootNode *rootNode;
};
#endif // !Fl_Preferences_H
//
// End of "$Id: Fl_Preferences.H 6770 2009-04-18 18:52:59Z matt $".
// End of "$Id: Fl_Preferences.H 7672 2010-07-10 09:44:45Z matt $".
//

View File

@@ -0,0 +1,270 @@
//
// "$Id: Fl_Printer.H 7662 2010-07-01 15:35:28Z manolo $"
//
// Printing support for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
/** \file Fl_Printer.H
\brief declaration of classes Fl_System_Printer, Fl_PostScript_Printer, Fl_Printer, Fl_Device_Plugin.
*/
#ifndef Fl_Printer_H
#define Fl_Printer_H
#include <FL/Fl_Paged_Device.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Pixmap.H>
#include <FL/Fl_RGB_Image.H>
#include <FL/Fl_Bitmap.H>
#include <stdio.h>
#if !(defined(__APPLE__) || defined(WIN32))
#include <FL/Fl_PostScript.H>
#endif
#if defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN)
/**
\brief Print support under MSWindows and Mac OS X.
*
Use Fl_Printer instead that is cross-platform and has the same API.
Fl_Printer is typedef'ed to Fl_System_Printer under MSWindows and Mac OS X.
*/
class Fl_System_Printer : public Fl_Paged_Device {
private:
/** \brief the printer's graphics context, if there's one, NULL otherwise */
void *gc;
void set_current();
#ifdef __APPLE__
float scale_x;
float scale_y;
float angle; // rotation angle in radians
PMPrintSession printSession;
PMPageFormat pageFormat;
PMPrintSettings printSettings;
#elif defined(WIN32)
int abortPrint;
PRINTDLG pd;
HDC hPr;
int prerr;
int left_margin;
int top_margin;
void absolute_printable_rect(int *x, int *y, int *w, int *h);
#endif
public:
static const char *device_type;
/**
@brief The constructor.
*/
Fl_System_Printer(void);
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
int start_page (void);
int printable_rect(int *w, int *h);
void margins(int *left, int *top, int *right, int *bottom);
void origin(int x, int y);
void scale (float scale_x, float scale_y);
void rotate(float angle);
void translate(int x, int y);
void untranslate(void);
int end_page (void);
void end_job (void);
/**
@brief The destructor.
*/
~Fl_System_Printer(void);
#ifndef FL_DOXYGEN
public:
static const char *dialog_title;
static const char *dialog_printer;
static const char *dialog_range;
static const char *dialog_copies;
static const char *dialog_all;
static const char *dialog_pages;
static const char *dialog_from;
static const char *dialog_to;
static const char *dialog_properties;
static const char *dialog_copyNo;
static const char *dialog_print_button;
static const char *dialog_cancel_button;
static const char *dialog_print_to_file;
static const char *property_title;
static const char *property_pagesize;
static const char *property_mode;
static const char *property_use;
static const char *property_save;
static const char *property_cancel;
#endif // FL_DOXYGEN
}; // class Fl_System_Printer
/** \brief OS-independant class name */
typedef Fl_System_Printer Fl_Printer;
#endif
#if !(defined(__APPLE__) || defined(WIN32))
/**
\brief Print support under Unix/Linux.
*
Use Fl_Printer instead that is cross-platform and has the same API.
Fl_Printer is typedef'ed to Fl_PostScript_Printer under Unix/Linux.
*/
class Fl_PostScript_Printer : public Fl_PostScript_File_Device {
private:
void set_current();
public:
static const char *device_type;
int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL);
#ifndef FL_DOXYGEN
static const char *dialog_title;
static const char *dialog_printer;
static const char *dialog_range;
static const char *dialog_copies;
static const char *dialog_all;
static const char *dialog_pages;
static const char *dialog_from;
static const char *dialog_to;
static const char *dialog_properties;
static const char *dialog_copyNo;
static const char *dialog_print_button;
static const char *dialog_cancel_button;
static const char *dialog_print_to_file;
static const char *property_title;
static const char *property_pagesize;
static const char *property_mode;
static const char *property_use;
static const char *property_save;
static const char *property_cancel;
#endif // FL_DOXYGEN
};
/** \brief OS-independant class name */
typedef Fl_PostScript_Printer Fl_Printer;
#endif
/**
* @brief OS-independent print support.
*
Fl_Printer allows to use all FLTK drawing, color, text, and clip functions, and to have them operate
on printed page(s). There are two main, non exclusive, ways to use it.
<ul><li>Print any widget (standard, custom, Fl_Window, Fl_Gl_Window) as it appears
on screen, with optional translation, scaling and rotation. This is done by calling print_widget()
or print_window_part().
<li>Use a series of FLTK graphics commands (e.g., font, text, lines, colors, clip) to
compose a page appropriately shaped for printing.
</ul>
In both cases, begin by start_job(), start_page(), printable_rect() and origin() calls
and finish by end_page() and end_job() calls.
<p><b>Platform specifics</b>
<br>Fl_Printer is typedef'ed to Fl_PostScript_Printer under Unix/Linux
and to Fl_System_Printer otherwise. Both classes have the same API.
<ul>
<li>Unix/Linux platforms:
Class Fl_RGB_Image prints but loses its transparency if it has one.
PostScript text output is presently restricted to the Latin alphabet.
Use the static public attributes of this class to set the print dialog to other languages
than English. For example, the "Printer:" dialog item Fl_Printer::dialog_printer can be set to French with:
\code
Fl_Printer::dialog_printer = "Imprimante:";
\endcode
before creation of the Fl_Printer object.
Use Fl_PostScript_File_Device::file_chooser_title to customize the title of the file chooser dialog that opens
when using the "Print To File" option of the print dialog.
<li>MSWindows platform: Transparent Fl_RGB_Image 's don't print with exact transparency on most printers.
Fl_RGB_Image 's don't rotate() well.
A workaround is to use the print_window_part() call.
<li>Mac OS X platform: all graphics requests print as on display.
</ul>
*/
#ifdef FL_DOXYGEN
// this class is NOT compiled. It's here for Doxygen documentation purpose only
class Fl_Printer : public Fl_System_Printer, Fl_PostScript_Printer {
public:
static const char *device_type;
/** @brief The constructor */
Fl_Printer(void);
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
int start_page(void);
int printable_rect(int *w, int *h);
void margins(int *left, int *top, int *right, int *bottom);
void origin(int x, int y);
void scale(float scale_x, float scale_y);
void rotate(float angle);
void translate(int x, int y);
void untranslate(void);
int end_page (void);
void end_job (void);
/** @brief The destructor */
~Fl_Printer(void);
/** \name These attributes are effective under the Xlib platform only.
\{
*/
static const char *dialog_title;
static const char *dialog_printer;
static const char *dialog_range;
static const char *dialog_copies;
static const char *dialog_all;
static const char *dialog_pages;
static const char *dialog_from;
static const char *dialog_to;
static const char *dialog_properties;
static const char *dialog_copyNo;
static const char *dialog_print_button;
static const char *dialog_cancel_button;
static const char *dialog_print_to_file;
static const char *property_title;
static const char *property_pagesize;
static const char *property_mode;
static const char *property_use;
static const char *property_save;
static const char *property_cancel;
/** \} */
};
#endif
/**
This plugin socket allows the integration of new device drivers for special
window or screen types. It is currently used to provide an automated printing
service for OpenGL windows, if linked with fltk_gl.
*/
class Fl_Device_Plugin : public Fl_Plugin {
public:
/** \brief The constructor */
Fl_Device_Plugin(const char *name)
: Fl_Plugin(klass(), name) { }
/** \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) { return 0; }
};
#endif // Fl_Printer_H
//
// End of "$Id: Fl_Printer.H 7662 2010-07-01 15:35:28Z manolo $"
//

View File

@@ -0,0 +1,35 @@
//
// "$Id: Fl_RGB_Image.H 6942 2009-11-18 12:22:51Z AlbrechtS $"
//
// RGB Image header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2009 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#ifndef Fl_RGB_Image_H
# define Fl_RGB_Image_H
# include "Fl_Image.H"
#endif // !Fl_RGB_Image_H
//
// End of "$Id: Fl_RGB_Image.H 6942 2009-11-18 12:22:51Z AlbrechtS $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Scroll.H 6828 2009-07-12 00:15:06Z greg.ercolano $"
// "$Id: Fl_Scroll.H 6951 2009-12-06 22:21:55Z matt $"
//
// Scroll header file for the Fast Light Tool Kit (FLTK).
//
@@ -39,19 +39,21 @@
larger than your window. If the child widgets are larger than the size
of this object then scrollbars will appear so that you can scroll over
to them:
<P ALIGN=CENTER>\image html Fl_Scroll.gif </P>
\image html Fl_Scroll.gif
\image latex Fl_Scroll.eps "Fl_Scroll" width=4cm
<P>If all of the child widgets are packed together into a solid
If all of the child widgets are packed together into a solid
rectangle then you want to set box() to FL_NO_BOX or
one of the _FRAME types. This will result in the best output.
However, if the child widgets are a sparse arrangment you must set
box() to a real _BOX type. This can result in some
However, if the child widgets are a sparse arrangement you must
set box() to a real _BOX type. This can result in some
blinking during redrawing, but that can be solved by using a
Fl_Double_Window. </P>
Fl_Double_Window.
By default you can scroll in both directions, and the scrollbars
disappear if the data will fit in the area of the scroll.
<P>Use Fl_Scroll::type() to change this as follows :
Use Fl_Scroll::type() to change this as follows :
<UL>
<LI>0 - No scrollbars </LI>
<LI>Fl_Scroll::HORIZONTAL - Only a horizontal scrollbar. </LI>
@@ -62,38 +64,38 @@
<LI>Fl_Scroll::BOTH_ALWAYS - Both always on. </LI>
</UL>
<P> Use <B> scrollbar.align(int) ( see void Fl_Widget::align(Fl_Align) ) :</B>
to change what side the scrollbars are drawn on.<BR>If the
FL_ALIGN_LEFT bit is on, the vertical scrollbar is on the left.
Use <B> scrollbar.align(int) ( see void Fl_Widget::align(Fl_Align) ) :</B>
to change what side the scrollbars are drawn on.
If the FL_ALIGN_LEFT bit is on, the vertical scrollbar is on the left.
If the FL_ALIGN_TOP bit is on, the horizontal scrollbar is on
the top. Note that only the alignment flags in scrollbar are
considered. The flags in hscrollbar however are ignored.
<P>This widget can also be used to pan around a single child widget
This widget can also be used to pan around a single child widget
"canvas". This child widget should be of your own class, with a
draw() method that draws the contents. The scrolling is done by
changing the x() and y() of the widget, so this child
must use the x() and y() to position it's drawing.
must use the x() and y() to position its drawing.
To speed up drawing it should test fl_push_clip().
<P>Another very useful child is a single
Fl_Pack, which is itself a group that packs it's children
together and changes size to surround them. Filling the Fl_Pack
with Fl_Tabs groups (and then putting
Another very useful child is a single Fl_Pack, which is itself a group
that packs its children together and changes size to surround them.
Filling the Fl_Pack with Fl_Tabs groups (and then putting
normal widgets inside those) gives you a very powerful scrolling list
of individually-openable panels. </P>
of individually-openable panels.
<P>Fluid lets you create these, but you can only lay out objects that
Fluid lets you create these, but you can only lay out objects that
fit inside the Fl_Scroll without scrolling. Be sure to leave
space for the scrollbars, as Fluid won't show these either. </P>
<P><I>You cannot use Fl_Window as a child of this since the
space for the scrollbars, as Fluid won't show these either.
<I>You cannot use Fl_Window as a child of this since the
clipping is not conveyed to it when drawn, and it will draw over the
scrollbars and neighboring objects.</I>
*/
class FL_EXPORT Fl_Scroll : public Fl_Group {
int xposition_, yposition_;
int width_, height_;
int oldx, oldy;
int scrollbar_size_;
static void hscrollbar_cb(Fl_Widget*, void*);
@@ -193,5 +195,5 @@ public:
#endif
//
// End of "$Id: Fl_Scroll.H 6828 2009-07-12 00:15:06Z greg.ercolano $".
// End of "$Id: Fl_Scroll.H 6951 2009-12-06 22:21:55Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Shared_Image.H 6614 2009-01-01 16:11:32Z matt $"
// "$Id: Fl_Shared_Image.H 7505 2010-04-14 20:47:34Z manolo $"
//
// Shared image header file for the Fast Light Tool Kit (FLTK).
//
@@ -25,8 +25,8 @@
// http://www.fltk.org/str.php
//
/* \file
Fl_Shared_Image class . */
/** \file
Fl_Shared_Image class. */
#ifndef Fl_Shared_Image_H
# define Fl_Shared_Image_H
@@ -106,5 +106,5 @@ FL_EXPORT extern void fl_register_images();
#endif // !Fl_Shared_Image_H
//
// End of "$Id: Fl_Shared_Image.H 6614 2009-01-01 16:11:32Z matt $"
// End of "$Id: Fl_Shared_Image.H 7505 2010-04-14 20:47:34Z manolo $"
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Sys_Menu_Bar.H 6614 2009-01-01 16:11:32Z matt $"
// "$Id: Fl_Sys_Menu_Bar.H 7518 2010-04-16 19:27:28Z manolo $"
//
// MacOS system menu bar header file for the Fast Light Tool Kit (FLTK).
//
@@ -29,28 +29,52 @@
#define Fl_Sys_Menu_Bar_H
#include "Fl_Menu_Bar.H"
#include "x.H"
#ifdef __APPLE__
#if defined(__APPLE__) || defined(FL_DOXYGEN)
/**
@brief A class to create, modify and delete menus that appear on Mac OS X in the menu bar at the top of the screen.
*
* On other than Mac OS X platforms, Fl_Sys_Menu_Bar is a synonym of class Fl_Menu_Bar.
*/
class FL_EXPORT Fl_Sys_Menu_Bar : public Fl_Menu_Bar {
protected:
void draw();
public:
/**
@brief The constructor.
*
* On Mac OS X, all arguments are unused. On other platforms they are used as by Fl_Menu_Bar::Fl_Menu_Bar().
*/
Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l=0)
: Fl_Menu_Bar(x,y,w,h,l) {
deactivate(); // don't let the old area take events
}
deactivate(); // don't let the old area take events
fl_sys_menu_bar = this;
}
void menu(const Fl_Menu_Item *m);
int add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0);
int insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data=0, int flags=0);
void remove(int n);
void replace(int rank, const char *name);
void clear();
int clear_submenu(int index);
#if ! defined(FL_DOXYGEN)
enum menuOrItemOperation { itemAtIndex, setKeyEquivalent, setKeyEquivalentModifierMask, setState, initWithTitle,
numberOfItems, setSubmenu, setEnabled, addSeparatorItem, setTitle, removeItem, addNewItem, renameItem };
// function doMenuOrItemOperation is in file Fl_cocoa.mm because it contains objective-c code
static void *doMenuOrItemOperation( menuOrItemOperation operation, ...);
#endif
};
#else
typedef Fl_Menu_Bar Fl_Sys_Menu_Bar;
#endif
#endif // defined(__APPLE__) || defined(FL_DOXYGEN)
#endif
#endif // Fl_Sys_Menu_Bar_H
//
// End of "$Id: Fl_Sys_Menu_Bar.H 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: Fl_Sys_Menu_Bar.H 7518 2010-04-16 19:27:28Z manolo $".
//

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,213 @@
//
// "$Id: Fl_Table_Row.H 6942 2009-11-18 12:22:51Z AlbrechtS $"
//
#ifndef _FL_TABLE_ROW_H
#define _FL_TABLE_ROW_H
//
// Fl_Table_Row -- A row oriented table widget
//
// A class specializing in a table of rows.
// Handles row-specific selection behavior.
//
// Copyright 2002 by Greg Ercolano.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "erco at seriss dot com".
//
//
#include "Fl_Table.H"
/**
A table with row selection capabilities.
This class implements a simple table of rows and columns that specializes in
the selection of rows. This widget is similar in behavior to a "mail subject
browser", similar to that found in mozilla, netscape and outlook mail browsers.
Most methods of importance will be found in the Fl_Table widget, such as
Fl_Table::rows() and Fl_Table::cols().
To be useful it must be subclassed and at minimum the draw_cell()
method must be overridden to provide the content of the cells. This widget
does \em not manage the cell's data content; it is up to the parent
class's draw_cell() method override to provide this.
Events on the cells and/or headings generate callbacks when they are
clicked by the user. You control when events are generated based on
the values you supply for Fl_Table::when().
*/
class Fl_Table_Row : public Fl_Table {
public:
enum TableRowSelectMode {
SELECT_NONE, // no selection allowed
SELECT_SINGLE, // single row selection
SELECT_MULTI // multiple row selection (default)
};
private:
// An STL-ish vector without templates
class CharVector {
char *arr;
int _size;
void init() {
arr = NULL;
_size = 0;
}
void copy(char *newarr, int newsize) {
size(newsize);
memcpy(arr, newarr, newsize * sizeof(char));
}
public:
CharVector() { // CTOR
init();
}
~CharVector() { // DTOR
if ( arr ) free(arr);
arr = NULL;
}
CharVector(CharVector&o) { // COPY CTOR
init();
copy(o.arr, o._size);
}
CharVector& operator=(CharVector&o) { // ASSIGN
init();
copy(o.arr, o._size);
return(*this);
}
char operator[](int x) const {
return(arr[x]);
}
char& operator[](int x) {
return(arr[x]);
}
int size() {
return(_size);
}
void size(int count) {
if ( count != _size ) {
arr = (char*)realloc(arr, count * sizeof(char));
_size = count;
}
}
char pop_back() {
char tmp = arr[_size-1];
_size--;
return(tmp);
}
void push_back(char val) {
int x = _size;
size(_size+1);
arr[x] = val;
}
char back() {
return(arr[_size-1]);
}
};
CharVector _rowselect; // selection flag for each row
// handle() state variables.
// Put here instead of local statics in handle(), so more
// than one instance can exist without crosstalk between.
//
int _dragging_select; // dragging out a selection?
int _last_row;
int _last_y; // last event's Y position
int _last_push_x; // last PUSH event's X position
int _last_push_y; // last PUSH event's Y position
TableRowSelectMode _selectmode;
protected:
int handle(int event);
int find_cell(TableContext context, // find cell's x/y/w/h given r/c
int R, int C, int &X, int &Y, int &W, int &H) {
return(Fl_Table::find_cell(context, R, C, X, Y, W, H));
}
public:
/**
The constructor for the Fl_Table_Row.
This creates an empty table with no rows or columns,
with headers and row/column resize behavior disabled.
*/
Fl_Table_Row(int X, int Y, int W, int H, const char *l=0) : Fl_Table(X,Y,W,H,l) {
_dragging_select = 0;
_last_row = -1;
_last_y = -1;
_last_push_x = -1;
_last_push_y = -1;
_selectmode = SELECT_MULTI;
}
/**
The destructor for the Fl_Table_Row.
Destroys the table and its associated widgets.
*/
~Fl_Table_Row() { }
void rows(int val); // set number of rows
int rows() { // get number of rows
return(Fl_Table::rows());
}
/**
Sets the table selection mode.
- \p Fl_Table_Row::SELECT_NONE - No selection allowed
- \p Fl_Table_Row::SELECT_SINGLE - Only single rows can be selected
- \p Fl_Table_Row::SELECT_MULTI - Multiple rows can be selected
*/
void type(TableRowSelectMode val); // set selection mode
TableRowSelectMode type() const { // get selection mode
return(_selectmode);
}
/**
Checks to see if 'row' is selected. Returns 1 if selected, 0 if not. You can
change the selection of a row by clicking on it, or by using
select_row(row, flag)
*/
int row_selected(int row); // is row selected? (0=no, 1=yes, -1=range err)
/**
Changes the selection state for 'row', depending on the value
of 'flag'. 0=deselected, 1=select, 2=toggle existing state.
*/
int select_row(int row, int flag=1); // select state for row: flag:0=off, 1=on, 2=toggle
// returns: 0=no change, 1=changed, -1=range err
/**
This convenience function changes the selection state
for \em all rows based on 'flag'. 0=deselect, 1=select, 2=toggle existing state.
*/
void select_all_rows(int flag=1); // all rows to a known state
void clear() {
rows(0); // implies clearing selection
cols(0);
Fl_Table::clear(); // clear the table
}
};
#endif /*_FL_TABLE_ROW_H*/
//
// End of "$Id: Fl_Table_Row.H 6942 2009-11-18 12:22:51Z AlbrechtS $".
//

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Text_Display.H 6902 2009-09-27 11:06:56Z matt $"
// "$Id: Fl_Text_Display.H 7527 2010-04-18 14:33:33Z engelsman $"
//
// Header file for Fl_Text_Display class.
//
@@ -251,7 +251,7 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group {
bool countLastLineMissingNewLine = true) const;
void find_line_end(int pos, bool start_pos_is_line_start, int *lineEnd,
int *nextLineStart) const;
int measure_proportional_character(char c, int colNum, int pos) const;
int measure_proportional_character(const char *s, int colNum, int pos) const;
int wrap_uses_character(int lineEndPos) const;
int range_touches_selection(const Fl_Text_Selection *sel, int rangeStart,
int rangeEnd) const;
@@ -340,5 +340,5 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group {
#endif
//
// End of "$Id: Fl_Text_Display.H 6902 2009-09-27 11:06:56Z matt $".
// End of "$Id: Fl_Text_Display.H 7527 2010-04-18 14:33:33Z engelsman $".
//

View File

@@ -0,0 +1,699 @@
//
// "$Id: Fl_Tree.H 7672 2010-07-10 09:44:45Z matt $"
//
#ifndef FL_TREE_H
#define FL_TREE_H
#include <FL/Fl.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Scrollbar.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Tree_Item.H>
#include <FL/Fl_Tree_Prefs.H>
//////////////////////
// FL/Fl_Tree.H
//////////////////////
//
// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
// Copyright (C) 2009 by Greg Ercolano.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
///
/// \file
/// \brief This file contains the definitions of the Fl_Tree class
///
/// \class Fl_Tree
///
/// \brief Tree widget.
///
/// \code
/// Fl_Tree // Top level widget
/// |--- Fl_Tree_Item // Items in the tree
/// |--- Fl_Tree_Prefs // Preferences for the tree
/// |--- Fl_Tree_Connector (enum) // Connection modes
/// |--- Fl_Tree_Select (enum) // Selection modes
/// |--- Fl_Tree_Sort (enum) // Sort behavior
/// \endcode
///
/// An expandable tree widget.
///
/// Similar to Fl_Browser, Fl_Tree is browser of Fl_Tree_Item's, which can be
/// in a parented hierarchy. Subtrees can be expanded or closed. Items can be
/// added, deleted, inserted, sorted and re-ordered.
///
/// The tree items may also contain other FLTK widgets, like buttons, input fields,
/// or even "custom" widgets.
///
/// The callback() is invoked depending on the value of when():
///
/// - FL_WHEN_RELEASE -- callback invoked when left mouse button is released on an item
/// - FL_WHEN_CHANGED -- callback invoked when left mouse changes selection state
///
/// The simple way to define a tree:
/// \code
/// #include <FL/Fl_Tree.H>
/// [..]
/// Fl_Tree tree(X,Y,W,H);
/// tree.begin();
/// tree.add("Flintstones/Fred");
/// tree.add("Flintstones/Wilma");
/// tree.add("Flintstones/Pebbles");
/// tree.add("Simpsons/Homer");
/// tree.add("Simpsons/Marge");
/// tree.add("Simpsons/Bart");
/// tree.add("Simpsons/Lisa");
/// tree.end();
/// \endcode
///
/// Items can be added with Fl_Tree::add(),
/// removed with Fl_Tree::remove(),
/// inserted with Fl_Tree::insert_above(),
/// selected/deselected with Fl_Tree::select() and Fl_Tree::deselect().
/// Items can be swapped with Fl_Tree_Item::swap_children(), sorting control via
/// Fl_Tree::sortorder().
///
/// The tree can have different selection behaviors controlled by Fl_Tree::selectmode().
///
/// FLTK and custom FLTK widgets can be assigned to tree items via Fl_Tree_Item::widget().
///
/// Parent nodes can be open/closed with open() and close(), icons can be assigned
/// or redefined with some or all items via
/// Fl_Tree_Item::openicon(),
/// Fl_Tree_Item::closeicon(),
/// Fl_Tree_Item::usericon().
///
/// Various default preferences can be manipulated via Fl_Tree_Prefs, including
/// colors, margins, connection lines.
///
/// \image html tree-elements.png
///
/// \todo Needs handling of callbacks when items are procedurally select()ed
///
class Fl_Tree : public Fl_Group {
Fl_Tree_Item *_root; // can be null!
Fl_Tree_Item *_item_clicked;
Fl_Tree_Prefs _prefs; // all the tree's settings
Fl_Scrollbar *_vscroll;
public:
/// Find the item that was clicked.
/// You probably want to use item_clicked() instead, which is fast.
///
/// This method walks the entire tree looking for the first item that is
/// under the mouse (ie. at Fl::event_x()/Fl:event_y().
///
/// Use this method /only/ if you've subclassed Fl_Tree, and are receiving
/// events before Fl_Tree has been able to process and update item_clicked().
///
/// \returns the item clicked, or 0 if no item was under the current event.
///
const Fl_Tree_Item *find_clicked() const {
if ( ! _root ) return(0);
return(_root->find_clicked(_prefs));
}
protected:
/// Set the item that was last clicked.
/// Should only be used by subclasses needing to change this value.
/// Normally Fl_Tree manages this value.
///
void item_clicked(Fl_Tree_Item* val) {
_item_clicked = val;
}
void do_callback_for_item(Fl_Tree_Item* item) {
Fl_Tree_Item *save = _item_clicked; // save previous 'item_clicked'
_item_clicked = item; // set item_clicked to this item while we do callback
do_callback((Fl_Widget*)this, user_data());
_item_clicked = save; // restore item_clicked
}
public:
Fl_Tree(int X, int Y, int W, int H, const char *L=0);
~Fl_Tree();
int handle(int e);
void draw();
///////////////////////
// root methods
///////////////////////
/// Set the label for the root item.
///
/// Makes an internally managed copy of 'new_label'.
///
void root_label(const char *new_label) {
if ( ! _root ) return;
_root->label(new_label);
}
/// Returns the root item.
Fl_Tree_Item* root() {
return(_root);
}
////////////////////////////////
// Item creation/removal methods
////////////////////////////////
Fl_Tree_Item *add(const char *path);
Fl_Tree_Item* add(Fl_Tree_Item *item, const char *name);
Fl_Tree_Item *insert_above(Fl_Tree_Item *above, const char *name);
Fl_Tree_Item* insert(Fl_Tree_Item *item, const char *name, int pos);
/// Remove the specified \p item from the tree.
/// If it has children, all those are removed too.
/// \returns 0 if done, -1 if 'item' not found.
///
int remove(Fl_Tree_Item *item) {
if ( !item ) return(0);
if ( item == _root ) {
clear();
} else {
Fl_Tree_Item *parent = item->parent(); // find item's parent
if ( ! parent ) return(-1);
parent->remove_child(item); // remove child + children
}
return(0);
}
/// Clear all children from the tree.
/// The tree will be left completely empty.
///
void clear() {
if ( ! _root ) return;
_root->clear_children();
delete _root; _root = 0;
}
/// Clear all the children of a particular node in the tree specified by \p item.
void clear_children(Fl_Tree_Item *item) {
if ( item->has_children() ) {
item->clear_children();
redraw(); // redraw only if there were children to clear
}
}
////////////////////////
// Item lookup methods
////////////////////////
Fl_Tree_Item *find_item(const char *path);
const Fl_Tree_Item *find_item(const char *path) const;
/// Return the item that was last clicked.
///
/// Valid only from within an Fl_Tree::callback().
///
/// \returns the item clicked, or 0 if none.
/// 0 may also be used to indicate several items were clicked/changed.
///
Fl_Tree_Item *item_clicked() {
return(_item_clicked);
}
/// Returns the first item in the tree.
///
/// Use this to walk the tree in the forward direction, eg:
/// \code
/// for ( Fl_Tree_Item *item = tree->first(); item; item = item->next() ) {
/// printf("Item: %s\n", item->label());
/// }
/// \endcode
///
/// \returns first item in tree, or 0 if none (tree empty).
///
Fl_Tree_Item *first() {
return(_root); // first item always root
}
/// Returns the last item in the tree.
///
/// Use this to walk the tree in reverse, eg:
///
/// \code
/// for ( Fl_Tree_Item *item = tree->last(); item; item = item->prev() ) {
/// printf("Item: %s\n", item->label());
/// }
/// \endcode
///
/// \returns last item in the tree, or 0 if none (tree empty).
///
Fl_Tree_Item *last() {
if ( ! _root ) return(0);
Fl_Tree_Item *item = _root;
while ( item->has_children() ) {
item = item->child(item->children()-1);
}
return(item);
}
//////////////////////////
// Item open/close methods
//////////////////////////
/// Open the specified 'item'.
/// This causes the item's children (if any) to be shown.
/// Handles redrawing if anything was actually changed.
///
void open(Fl_Tree_Item *item) {
if ( ! item->is_open() ) {
item->open();
redraw();
}
}
/// Opens the item specified by \p path (eg: "Parent/child/item").
/// This causes the item's children (if any) to be shown.
/// Handles redrawing if anything was actually changed.
///
/// \returns
/// - 0 : OK
/// - -1 : item was not found
///
int open(const char *path) {
Fl_Tree_Item *item = find_item(path);
if ( item ) {
open(item);
return(0);
}
return(-1);
}
/// Closes the specified \p item.
/// Handles redrawing if anything was actually changed.
///
void close(Fl_Tree_Item *item) {
if ( ! item->is_close() ) {
item->close();
redraw();
}
}
/// Closes the item specified by \p path, eg: "Parent/child/item".
///
/// Handles redrawing if anything was actually changed.
///
/// \returns
/// - 0 -- OK
/// - -1 -- item was not found
///
int close(const char *path) {
Fl_Tree_Item *item = find_item(path);
if ( item ) {
close(item);
return(0);
}
return(-1);
}
/// See if \p item is open.
///
/// Items that are 'open' are themselves not necessarily visible;
/// one of the item's parents might be closed.
///
/// \returns
/// - 1 : item is open
/// - 0 : item is closed
///
int is_open(Fl_Tree_Item *item) const {
return(item->is_open()?1:0);
}
/// See if item specified by \p path (eg: "Parent/child/item") is open.
///
/// Items that are 'open' are themselves not necessarily visible;
/// one of the item's parents might be closed.
///
/// \returns
/// - 1 : item is open
/// - 0 : item is closed
/// - -1 : item was not found
///
int is_open(const char *path) const {
const Fl_Tree_Item *item = find_item(path);
if ( item ) return(item->is_open()?1:0);
return(-1);
}
/// See if the specified \p item is closed.
/// \returns
/// - 1 : item is open
/// - 0 : item is closed
///
int is_close(Fl_Tree_Item *item) const {
return(item->is_close());
}
/// See if item specified by \p path (eg: "Parent/child/item") is closed.
///
/// \returns
/// - 1 : item is closed
/// - 0 : item is open
/// - -1 : item was not found
///
int is_close(const char *path) const {
const Fl_Tree_Item *item = find_item(path);
if ( item ) return(item->is_close()?1:0);
return(-1);
}
/////////////////////////
// Item selection methods
/////////////////////////
/// Select the specified \p item. Use 'deselect()' to de-select it.
/// Handles redrawing if anything was actually changed.
///
/// \p docallback is an optional paramemter that can either be 0 or 1.
/// - 0 - the callback() is not invoked (default)
/// - 1 - the callback() is invoked if the item changed state,
/// and the callback can use item_clicked() to determine the selected item.
///
void select(Fl_Tree_Item *item, int docallback=0) {
if ( ! item->is_selected() ) {
item->select();
if ( docallback == 1 ) do_callback_for_item(item);
redraw();
}
}
/// Select the item specified by \p path (eg: "Parent/child/item").
/// Handles redrawing if anything was actually changed.
///
/// \p docallback is an optional paramemter that can either be 0 or 1.
/// - 0 - the callback() is not invoked (default)
/// - 1 - the callback() is invoked if the item changed state,
/// and the callback can use item_clicked() to determine the selected item.
///
/// \returns
/// - 0 : OK
/// - -1 : item was not found
///
int select(const char *path, int docallback=0) {
Fl_Tree_Item *item = find_item(path);
if ( item ) {
select(item);
if ( docallback == 1 ) do_callback_for_item(item);
return(0);
}
return(-1);
}
/// Toggle the select state of the specified \p item.
/// Handles redrawing.
///
/// \p docallback is an optional paramemter that can either be 0 or 1.
/// - 0 - the callback() is not invoked (default)
/// - 1 - the callback() is invoked,
/// and the callback can use item_clicked() to determine the selected item.
///
void select_toggle(Fl_Tree_Item *item, int docallback=0) {
item->select_toggle();
if ( docallback == 1 ) do_callback_for_item(item);
redraw();
}
/// De-select the specified \p item.
/// Handles redrawing if anything was actually changed.
///
/// \p docallback is an optional paramemter that can either be 0 or 1.
/// - 0 - the callback() is not invoked (default)
/// - 1 - the callback() is invoked if the item changed state,
/// and the callback can use item_clicked() to determine the selected item.
///
void deselect(Fl_Tree_Item *item, int docallback=0) {
if ( item->is_selected() ) {
item->deselect();
if ( docallback == 1 ) do_callback_for_item(item);
redraw();
}
}
/// De-select an item specified by \p path (eg: "Parent/child/item").
/// Handles redrawing if anything was actually changed.
///
/// \p docallback is an optional paramemter that can either be 0 or 1.
/// - 0 - the callback() is not invoked (default)
/// - 1 - the callback() is invoked if the item changed state,
/// and the callback can use item_clicked() to determine the selected item.
///
/// \returns
/// - 0 : OK
/// - -1 : item was not found
///
int deselect(const char *path, int docallback=0) {
Fl_Tree_Item *item = find_item(path);
if ( item ) {
deselect(item, docallback);
return(0);
}
return(-1);
}
int deselect_all(Fl_Tree_Item *item=0, int docallback=0);
int select_only(Fl_Tree_Item *selitem, int docallback=0);
int select_all(Fl_Tree_Item *item=0, int docallback=0);
/// See if the specified \p item is selected.
/// \return
/// - 1 : item selected
/// - 0 : item deselected
///
int is_selected(Fl_Tree_Item *item) const {
return(item->is_selected()?1:0);
}
/// See if item specified by \p path (eg: "Parent/child/item") is selected.
///
/// \returns
/// - 1 : item selected
/// - 0 : item deselected
/// - -1 : item was not found
///
int is_selected(const char *path) {
Fl_Tree_Item *item = find_item(path);
if ( item ) return(is_selected(item));
return(-1);
}
/// Print the tree as 'ascii art' to stdout.
/// Used mainly for debugging.
///
void show_self() {
if ( ! _root ) return;
_root->show_self();
}
/////////////////////////////////
// Item attribute related methods
/////////////////////////////////
/// Get the default label fontsize used for creating new items.
int labelsize() const {
return(_prefs.labelsize());
}
/// Set the default label font size used for creating new items.
/// To change the font size on a per-item basis, use Fl_Tree_Item::labelsize(int)
///
void labelsize(int val) {
_prefs.labelsize(val);
}
/// Get the default font face used for item's labels when new items are created.
///
/// Don't use this if you want to change an existing label() size; use
/// item->labelfont() instead.
///
int labelfont() const {
return(_prefs.labelfont());
}
/// Set the default font face used for item's labels when new items are created.
///
/// Don't use this if you want to change an existing label() size; use
/// item->labelfont(int) instead.
///
void labelfont(int val) {
_prefs.labelfont(val);
}
/// Get the amount of white space (in pixels) that should appear
/// between the widget's left border and the tree's contents.
///
int marginleft() const {
return(_prefs.marginleft());
}
/// Set the amount of white space (in pixels) that should appear
/// between the widget's left border and the left side of the tree's contents.
///
void marginleft(int val) {
_prefs.marginleft(val);
redraw();
}
/// Get the amount of white space (in pixels) that should appear
/// between the widget's top border and the top of the tree's contents.
///
int margintop() const {
return(_prefs.margintop());
}
/// Sets the amount of white space (in pixels) that should appear
/// between the widget's top border and the top of the tree's contents.
///
void margintop(int val) {
_prefs.margintop(val);
redraw();
}
/// Get the amount of white space (in pixels) that should appear
/// below an open child tree's contents.
///
int openchild_marginbottom() const {
return(_prefs.openchild_marginbottom());
}
/// Set the amount of white space (in pixels) that should appear
/// below an open child tree's contents.
///
void openchild_marginbottom(int val) {
_prefs.openchild_marginbottom(val);
redraw();
}
/// Gets the width of the horizontal connection lines (in pixels)
/// that appear to the left of each tree item's label.
///
int connectorwidth() const {
return(_prefs.connectorwidth());
}
/// Sets the width of the horizontal connection lines (in pixels)
/// that appear to the left of each tree item's label.
///
void connectorwidth(int val) {
_prefs.connectorwidth(val);
redraw();
}
/// Returns the Fl_Image being used as the default user icon for newly created items.
/// Returns zero if no icon has been set, which is the default.
///
Fl_Image *usericon() const {
return(_prefs.usericon());
}
/// Sets the Fl_Image to be used as the default user icon for all
/// newly created items.
///
/// If you want to specify user icons on a per-item basis,
/// use Fl_Tree_Item::usericon() instead.
///
/// \param[in] val -- The new image to be used, or
/// zero to disable user icons.
///
void usericon(Fl_Image *val) {
_prefs.usericon(val);
redraw();
}
/// Returns the icon to be used as the 'open' icon.
/// If none was set, the internal default is returned,
/// a simple '[+]' icon.
///
Fl_Image *openicon() const {
return(_prefs.openicon());
}
/// Sets the icon to be used as the 'open' icon.
/// This overrides the built in default '[+]' icon.
///
/// \param[in] val -- The new image, or zero to use the default [+] icon.
///
void openicon(Fl_Image *val) {
_prefs.openicon(val);
redraw();
}
/// Returns the icon to be used as the 'close' icon.
/// If none was set, the internal default is returned,
/// a simple '[-]' icon.
///
Fl_Image *closeicon() const {
return(_prefs.closeicon());
}
/// Sets the icon to be used as the 'close' icon.
/// This overrides the built in default '[-]' icon.
///
/// \param[in] val -- The new image, or zero to use the default [-] icon.
///
void closeicon(Fl_Image *val) {
_prefs.closeicon(val);
redraw();
}
/// Returns 1 if the collapse icon is enabled, 0 if not.
int showcollapse() const {
return(_prefs.showcollapse());
}
/// Set if we should show the collapse icon or not.
/// If collapse icons are disabled, the user will not be able
/// to interactively collapse items in the tree, unless the application
/// provides some other means via open() and close().
///
/// \param[in] val 1: shows collapse icons (default),\n
/// 0: hides collapse icons.
///
void showcollapse(int val) {
_prefs.showcollapse(val);
redraw();
}
/// Returns 1 if the root item is to be shown, or 0 if not.
int showroot() const {
return(_prefs.showroot());
}
/// Set if the root item should be shown or not.
/// \param[in] val 1 -- show the root item (default)\n
/// 0 -- hide the root item.
///
void showroot(int val) {
_prefs.showroot(val);
redraw();
}
/// Returns the line drawing style for inter-connecting items.
Fl_Tree_Connector connectorstyle() const {
return(_prefs.connectorstyle());
}
/// Sets the line drawing style for inter-connecting items.
void connectorstyle(Fl_Tree_Connector val) {
_prefs.connectorstyle(val);
redraw();
}
/// Set the default sort order used when items are added to the tree.
/// See Fl_Tree_Sort for possible values.
///
Fl_Tree_Sort sortorder() const {
return(_prefs.sortorder());
}
/// Gets the sort order used to add items to the tree.
void sortorder(Fl_Tree_Sort val) {
_prefs.sortorder(val);
// no redraw().. only affects new add()itions
}
/// Sets the style of box used to draw selected items.
/// This is an fltk Fl_Boxtype.
/// The default is influenced by FLTK's current Fl::scheme()
///
Fl_Boxtype selectbox() const {
return(_prefs.selectbox());
}
/// Gets the style of box used to draw selected items.
/// This is an fltk Fl_Boxtype.
/// The default is influenced by FLTK's current Fl::scheme()
///
void selectbox(Fl_Boxtype val) {
_prefs.selectbox(val);
redraw();
}
/// Gets the tree's current selection mode.
Fl_Tree_Select selectmode() const {
return(_prefs.selectmode());
}
/// Sets the tree's selection mode.
void selectmode(Fl_Tree_Select val) {
_prefs.selectmode(val);
}
void load(class Fl_Preferences&);
};
#endif /*FL_TREE_H*/
//
// End of "$Id: Fl_Tree.H 7672 2010-07-10 09:44:45Z matt $".
//

View File

@@ -0,0 +1,321 @@
//
// "$Id: Fl_Tree_Item.H 6957 2009-12-08 08:39:31Z greg.ercolano $"
//
#ifndef FL_TREE_ITEM_H
#define FL_TREE_ITEM_H
#include <FL/Fl.H>
#include <FL/Fl_Widget.H>
#include <FL/Fl_Image.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Tree_Item_Array.H>
#include <FL/Fl_Tree_Prefs.H>
//////////////////////
// FL/Fl_Tree_Item.H
//////////////////////
//
// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
// Copyright (C) 2009 by Greg Ercolano.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
///
/// \file
/// \brief This file contains the definitions for Fl_Tree_Item
///
/// \brief Tree item
///
/// This class is a single tree item, and manages all of the item's attributes.
/// Fl_Tree_Item is used by Fl_Tree, which is comprised of many instances of Fl_Tree_Item.
///
/// Fl_Tree_Item is hierarchical; it dynamically manages an Fl_Tree_Item_Array of children
/// that are themselves instances of Fl_Tree_Item. Each item can have zero or more children.
/// When an item has children, close() and open() can be used to hide or show them.
///
/// Items have their own attributes; font size, face, color.
/// Items maintain their own hierarchy of children.
///
/// When you make changes to items, you'll need to tell the tree to redraw()
/// for the changes to show up.
///
class Fl_Tree_Item {
const char *_label; // label (memory managed)
int _labelfont; // label's font face
int _labelsize; // label's font size
Fl_Color _labelfgcolor; // label's fg color
Fl_Color _labelbgcolor; // label's bg color
char _open; // item is open?
char _visible; // item is visible?
char _active; // item activated?
char _selected; // item selected?
int _xywh[4]; // xywh of this widget (if visible)
int _collapse_xywh[4]; // xywh of collapse icon (if any)
int _label_xywh[4]; // xywh of label
Fl_Widget *_widget; // item's label widget (optional)
Fl_Image *_usericon; // item's user-specific icon (optional)
Fl_Tree_Item_Array _children; // array of child items
Fl_Tree_Item *_parent; // parent item (=0 if root)
void *_userdata; // user data that can be associated with an item
protected:
void show_widgets();
void hide_widgets();
void draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_Prefs &prefs);
void draw_horizontal_connector(int x1, int x2, int y, const Fl_Tree_Prefs &prefs);
public:
Fl_Tree_Item(const Fl_Tree_Prefs &prefs); // CTOR
~Fl_Tree_Item(); // DTOR
Fl_Tree_Item(const Fl_Tree_Item *o); // COPY CTOR
void draw(int X, int &Y, int W, Fl_Widget *tree, const Fl_Tree_Prefs &prefs, int lastchild=1);
void show_self(const char *indent = "") const;
void label(const char *val);
const char *label() const;
/// Set a user-data value for the item.
inline void user_data( void* data ) { _userdata = data; }
/// Retrieve the user-data value that has been assigned to the item.
inline void* user_data() const { return _userdata; }
/// Set item's label font face.
void labelfont(int val) {
_labelfont = val;
}
/// Get item's label font face.
int labelfont() const {
return(_labelfont);
}
/// Set item's label font size.
void labelsize(int val) {
_labelsize = val;
}
/// Get item's label font size.
int labelsize() const {
return(_labelsize);
}
/// Set item's label foreground text color.
void labelfgcolor(Fl_Color val) {
_labelfgcolor = val;
}
/// Set item's label text color.
void labelcolor(Fl_Color val) {
_labelfgcolor = val;
}
/// Return item's label text color.
Fl_Color labelcolor() const {
return(_labelfgcolor);
}
/// Return item's label foreground text color.
Fl_Color labelfgcolor() const {
return(_labelfgcolor);
}
/// Set item's label background color.
void labelbgcolor(Fl_Color val) {
_labelbgcolor = val;
}
/// Return item's background text color.
Fl_Color labelbgcolor() const {
return(_labelbgcolor);
}
/// Assign an FLTK widget to this item.
void widget(Fl_Widget *val) {
_widget = val;
}
/// Return FLTK widget assigned to this item.
Fl_Widget *widget() const {
return(_widget);
}
/// Return the number of children this item has.
int children() const {
return(_children.total());
}
/// Return the child item for the given 'index'.
Fl_Tree_Item *child(int index) {
return(_children[index]);
}
/// Return the const child item for the given 'index'.
const Fl_Tree_Item *child(int t) const;
/// See if this item has children.
int has_children() const {
return(children());
}
int find_child(const char *name);
int find_child(Fl_Tree_Item *item);
int remove_child(Fl_Tree_Item *item);
int remove_child(const char *new_label);
void clear_children();
void swap_children(int ax, int bx);
int swap_children(Fl_Tree_Item *a, Fl_Tree_Item *b);
const Fl_Tree_Item *find_item(char **arr) const;
Fl_Tree_Item *find_item(char **arr);
//////////////////
// Adding items
//////////////////
Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs, const char *new_label);
Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs, char **arr);
Fl_Tree_Item *insert(const Fl_Tree_Prefs &prefs, const char *new_label, int pos=0);
Fl_Tree_Item *insert_above(const Fl_Tree_Prefs &prefs, const char *new_label);
int depth() const;
Fl_Tree_Item *prev();
Fl_Tree_Item *next();
/// Return the parent for this item.
Fl_Tree_Item *parent() {
return(_parent);
}
/// Return the const parent for this item.
const Fl_Tree_Item *parent() const {
return(_parent);
}
/// Set the parent for this item.
/// Should only be used by Fl_Tree's internals.
///
void parent(Fl_Tree_Item *val) {
_parent = val;
}
//////////////////
// State
//////////////////
void open();
void close();
/// See if the item is 'open'.
int is_open() const {
return(_open?1:0);
}
/// See if the item is 'closed'.
int is_close() const {
return(_open?0:1);
}
/// Toggle the item's open/closed state.
void open_toggle() {
_open?close():open();
}
/// Change the item's selection state to the optionally specified 'val'.
/// If 'val' is not specified, the item will be selected.
///
void select(int val=1) {
_selected = val;
}
/// Toggle the item's selection state.
void select_toggle() {
if ( is_selected() ) {
deselect(); // deselect if selected
} else {
select(); // select if deselected
}
}
/// Select self and all children
/// Returns count of how many items were in the 'deselected' state,
/// ie. how many items were "changed".
///
int select_all() {
int count = 0;
if ( ! is_selected() ) {
select();
++count;
}
for ( int t=0; t<children(); t++ ) {
count += child(t)->select_all();
}
return(count);
}
/// Disable the item's selection state.
void deselect() {
_selected = 0;
}
/// Deselect self and all children
/// Returns count of how many items were in the 'selected' state,
/// ie. how many items were "changed".
///
int deselect_all() {
int count = 0;
if ( is_selected() ) {
deselect();
++count;
}
for ( int t=0; t<children(); t++ ) {
count += child(t)->deselect_all();
}
return(count);
}
/// See if the item is selected.
char is_selected() const {
return(_selected);
}
/// Change the item's activation state to the optionally specified 'val'.
///
/// When deactivated, the item will be 'grayed out'; the callback()
/// won't be invoked if the user clicks on the label. If the item
/// has a widget() associated with the item, its activation state
/// will be changed as well.
///
/// If 'val' is not specified, the item will be activated.
///
void activate(int val=1) {
_active = val;
if ( _widget && val != (int)_widget->active() ) {
if ( val ) {
_widget->activate();
} else {
_widget->deactivate();
}
_widget->redraw();
}
}
/// Deactivate the item; the callback() won't be invoked when clicked.
/// Same as activate(0)
///
void deactivate() {
activate(0);
}
/// See if the item is activated.
char is_activated() const {
return(_active);
}
/// See if the item is activated.
char is_active() const {
return(_active);
}
/// Set the user icon's image. '0' will disable.
void usericon(Fl_Image *val) {
_usericon = val;
}
/// Get the user icon. Returns '0' if disabled.
Fl_Image *usericon() const {
return(_usericon);
}
//////////////////
// Events
//////////////////
const Fl_Tree_Item *find_clicked(const Fl_Tree_Prefs &prefs) const;
Fl_Tree_Item *find_clicked(const Fl_Tree_Prefs &prefs);
int event_on_collapse_icon(const Fl_Tree_Prefs &prefs) const;
int event_on_label(const Fl_Tree_Prefs &prefs) const;
/// Is this item the root of the tree?
int is_root() const {
return(_parent==0?1:0);
}
};
#endif /*FL_TREE_ITEM_H*/
//
// End of "$Id: Fl_Tree_Item.H 6957 2009-12-08 08:39:31Z greg.ercolano $".
//

View File

@@ -0,0 +1,88 @@
//
// "$Id: Fl_Tree_Item_Array.H 6956 2009-12-08 08:06:44Z greg.ercolano $"
//
#ifndef _FL_TREE_ITEM_ARRAY_H
#define _FL_TREE_ITEM_ARRAY_H
class Fl_Tree_Item; // forward decl must *precede* first doxygen comment block
// or doxygen will not document our class..
//////////////////////////
// FL/Fl_Tree_Item_Array.H
//////////////////////////
//
// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
// Copyright (C) 2009 by Greg Ercolano.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
///
/// \file
/// \brief This file defines a class that manages an array of Fl_Tree_Item pointers.
///
/// \brief Manages an array of Fl_Tree_Item pointers.
///
/// Because FLTK 1.x.x. has mandated that templates and STL not be used,
/// we use this class to dynamically manage the arrays.
///
/// None of the methods do range checking on index values; the caller
/// must be sure that index values are within the range 0<index<total()
/// (unless otherwise noted).
///
class Fl_Tree_Item_Array {
Fl_Tree_Item **_items; // items array
int _total; // #items in array
int _size; // #items *allocated* for array
int _chunksize; // #items to enlarge mem allocation
void enlarge(int count);
public:
Fl_Tree_Item_Array(int new_chunksize = 10); // CTOR
~Fl_Tree_Item_Array(); // DTOR
Fl_Tree_Item_Array(const Fl_Tree_Item_Array *o); // COPY CTOR
/// Return the item and index \p i.
Fl_Tree_Item *operator[](int i) {
return(_items[i]);
}
/// Const version of operator[](int i)
const Fl_Tree_Item *operator[](int i) const {
return(_items[i]);
}
/// Return the total items in the array, or 0 if empty.
int total() const {
return(_total);
}
/// Swap the two items at index positions \p ax and \p bx.
void swap(int ax, int bx) {
Fl_Tree_Item *asave = _items[ax];
_items[ax] = _items[bx];
_items[bx] = asave;
}
void clear();
void add(Fl_Tree_Item *val);
void insert(int pos, Fl_Tree_Item *new_item);
void remove(int index);
int remove(Fl_Tree_Item *item);
};
#endif /*_FL_TREE_ITEM_ARRAY_H*/
//
// End of "$Id: Fl_Tree_Item_Array.H 6956 2009-12-08 08:06:44Z greg.ercolano $".
//

View File

@@ -0,0 +1,361 @@
//
// "$Id: Fl_Tree_Prefs.H 6956 2009-12-08 08:06:44Z greg.ercolano $"
//
#ifndef FL_TREE_PREFS_H
#define FL_TREE_PREFS_H
//////////////////////
// FL/Fl_Tree_Prefs.H
//////////////////////
//
// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
// Copyright (C) 2009 by Greg Ercolano.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
///
/// \file
/// \brief This file contains the definitions for Fl_Tree's preferences.
///
/// \code
/// Fl_Tree_Prefs
/// :
/// .....:.......
/// : :
/// Fl_Tree :
/// |_____ Fl_Tree_Item
///
/// \endcode
///
/// \class Fl_Tree_Prefs
/// \brief Tree widget's preferences.
/// \enum Fl_Tree_Sort
/// Sort order options for items added to the tree
///
enum Fl_Tree_Sort {
FL_TREE_SORT_NONE=0, ///< No sorting; items are added in the order defined (default).
FL_TREE_SORT_ASCENDING=1, ///< Add items in ascending sort order.
FL_TREE_SORT_DESCENDING=2 ///< Add items in descending sort order.
};
/// \enum Fl_Tree_Connector
/// Defines the style of connection lines between items.
///
enum Fl_Tree_Connector {
FL_TREE_CONNECTOR_NONE=0, ///< Use no lines connecting items
FL_TREE_CONNECTOR_DOTTED=1, ///< Use dotted lines connecting items (default)
FL_TREE_CONNECTOR_SOLID=2 ///< Use solid lines connecting items
};
/// \enum Fl_Tree_Select
/// Tree selection style.
///
enum Fl_Tree_Select {
FL_TREE_SELECT_NONE=0, ///< Nothing selected when items are clicked
FL_TREE_SELECT_SINGLE, ///< Single item selected when item is clicked (default)
FL_TREE_SELECT_MULTI ///< Multiple items can be selected by clicking with
///< SHIFT or CTRL or mouse drags.
};
/// \class Fl_Tree_Prefs
///
/// \brief Fl_Tree's Preferences class.
///
/// This class manages the Fl_Tree's defaults.
/// You should probably be using the methods in Fl_Tree
/// instead of trying to accessing tree's preferences settings directly.
///
class Fl_Tree_Prefs {
int _labelfont; // label's font face
int _labelsize; // label's font size
int _margintop; // --
int _marginleft; // |- tree's margins
//int _marginright; // |
//int _marginbottom; // --
int _openchild_marginbottom; // extra space below an open child tree
int _usericonmarginleft; // space to left of user icon (if any)
int _labelmarginleft; // space to left of label
int _connectorwidth; // connector width (right of open/close icon)
int _linespacing; // vertical space between lines
// Colors
Fl_Color _fgcolor; // label's foreground color
Fl_Color _bgcolor; // background color
Fl_Color _selectcolor; // selection color
Fl_Color _inactivecolor; // inactive color
Fl_Color _connectorcolor; // connector dotted line color
Fl_Tree_Connector _connectorstyle; // connector line style
Fl_Image *_openimage; // the 'open' icon [+]
Fl_Image *_closeimage; // the 'close' icon [-]
Fl_Image *_userimage; // user's own icon
char _showcollapse; // 1=show collapse icons, 0=don't
char _showroot; // show the root item as part of the tree
Fl_Tree_Sort _sortorder; // none, ascening, descending, etc.
Fl_Boxtype _selectbox; // selection box type
Fl_Tree_Select _selectmode; // selection mode
public:
Fl_Tree_Prefs();
////////////////////////////
// Labels
////////////////////////////
/// Return the label's font.
inline int labelfont() const {
return(_labelfont);
}
/// Set the label's font to \p val.
inline void labelfont(int val) {
_labelfont = val;
}
/// Return the label's size in pixels.
inline int labelsize() const {
return(_labelsize);
}
/// Set the label's size in pixels to \p val.
inline void labelsize(int val) {
_labelsize = val;
}
////////////////////////////
// Margins
////////////////////////////
/// Get the left margin's value in pixels
inline int marginleft() const {
return(_marginleft);
}
/// Set the left margin's value in pixels
inline void marginleft(int val) {
_marginleft = val;
}
/// Get the top margin's value in pixels
inline int margintop() const {
return(_margintop);
}
/// Set the top margin's value in pixels
inline void margintop(int val) {
_margintop = val;
}
/// Get the margin below an open child in pixels
inline int openchild_marginbottom() const {
return(_openchild_marginbottom);
}
/// Set the margin below an open child in pixels
inline void openchild_marginbottom(int val) {
_openchild_marginbottom = val;
}
/****** NOT IMPLEMENTED
inline int marginright() const {
return(_marginright);
}
inline void marginright(int val) {
_marginright = val;
}
inline int marginbottom() const {
return(_marginbottom);
}
inline void marginbottom(int val) {
_marginbottom = val;
}
*******/
/// Get the user icon's left margin value in pixels
inline int usericonmarginleft() const {
return(_usericonmarginleft);
}
/// Set the user icon's left margin value in pixels
inline void usericonmarginleft(int val) {
_usericonmarginleft = val;
}
/// Get the label's left margin value in pixels
inline int labelmarginleft() const {
return(_labelmarginleft);
}
/// Set the label's left margin value in pixels
inline void labelmarginleft(int val) {
_labelmarginleft = val;
}
/// Get the line spacing value in pixels
inline int linespacing() const {
return(_linespacing);
}
/// Set the line spacing value in pixels
inline void linespacing(int val) {
_linespacing = val;
}
////////////////////////////
// Colors and Styles
////////////////////////////
/// Get the default label foreground color
inline Fl_Color fgcolor() const {
return(_fgcolor);
}
/// Set the default label foreground color
inline void fgcolor(Fl_Color val) {
_fgcolor = val;
}
/// Get the default label background color
inline Fl_Color bgcolor() const {
return(_bgcolor);
}
/// Set the default label background color
inline void bgcolor(Fl_Color val) {
_bgcolor = val;
}
/// Get the default selection color
inline Fl_Color selectcolor() const {
return(_selectcolor);
}
/// Set the default selection color
inline void selectcolor(Fl_Color val) {
_selectcolor = val;
}
/// Get the default inactive color
inline Fl_Color inactivecolor() const {
return(_inactivecolor);
}
/// Set the default inactive color
inline void inactivecolor(Fl_Color val) {
_inactivecolor = val;
}
/// Get the connector color; the color used for tree connection lines
inline Fl_Color connectorcolor() const {
return(_connectorcolor);
}
/// Set the connector color; the color used for tree connection lines
inline void connectorcolor(Fl_Color val) {
_connectorcolor = val;
}
/// Get the connector style
inline Fl_Tree_Connector connectorstyle() const {
return(_connectorstyle);
}
/// Set the connector style
inline void connectorstyle(Fl_Tree_Connector val) {
_connectorstyle = val;
}
/// Set the connector style [integer].
inline void connectorstyle(int val) {
_connectorstyle = Fl_Tree_Connector(val);
}
/// Get the tree connection line's width
inline int connectorwidth() const {
return(_connectorwidth);
}
/// Set the tree connection line's width
inline void connectorwidth(int val) {
_connectorwidth = val;
}
////////////////////////////
// Icons
////////////////////////////
/// Get the current default 'open' icon.
/// Returns the Fl_Image* of the icon, or 0 if none.
///
inline Fl_Image *openicon() const {
return(_openimage);
}
void openicon(Fl_Image *val);
/// Gets the default 'close' icon
/// Returns the Fl_Image* of the icon, or 0 if none.
///
inline Fl_Image *closeicon() const {
return(_closeimage);
}
void closeicon(Fl_Image *val);
/// Gets the default 'user icon' (default is 0)
inline Fl_Image *usericon() const {
return(_userimage);
}
/// Sets the default 'user icon'
/// Returns the Fl_Image* of the icon, or 0 if none (default).
///
inline void usericon(Fl_Image *val) {
_userimage = val;
}
////////////////////////////
// Options
////////////////////////////
/// Returns 1 if the collapse icon is enabled, 0 if not.
inline char showcollapse() const {
return(_showcollapse);
}
/// Set if we should show the collapse icon or not.
/// If collapse icons are disabled, the user will not be able
/// to interactively collapse items in the tree, unless the application
/// provides some other means via open() and close().
///
/// \param[in] val 1: shows collapse icons (default),\n
/// 0: hides collapse icons.
///
inline void showcollapse(int val) {
_showcollapse = val;
}
/// Get the default sort order value
inline Fl_Tree_Sort sortorder() const {
return(_sortorder);
}
/// Set the default sort order value.
/// Defines the order new items appear when add()ed to the tree.
/// See Fl_Tree_Sort for possible values.
///
inline void sortorder(Fl_Tree_Sort val) {
_sortorder = val;
}
/// Get the default selection box's box drawing style as an Fl_Boxtype.
inline Fl_Boxtype selectbox() const {
return(_selectbox);
}
/// Set the default selection box's box drawing style to \p val.
inline void selectbox(Fl_Boxtype val) {
_selectbox = val;
}
/// Returns 1 if the root item is to be shown, or 0 if not.
inline int showroot() const {
return(int(_showroot));
}
/// Set if the root item should be shown or not.
/// \param[in] val 1 -- show the root item (default)\n
/// 0 -- hide the root item.
///
inline void showroot(int val) {
_showroot = char(val);
}
/// Get the selection mode used for the tree
inline Fl_Tree_Select selectmode() const {
return(_selectmode);
}
/// Set the selection mode used for the tree to \p val.
/// This affects how items in the tree are selected
/// when clicked on and dragged over by the mouse.
/// See Fl_Tree_Select for possible values.
///
inline void selectmode(Fl_Tree_Select val) {
_selectmode = val;
}
};
#endif /*FL_TREE_PREFS_H*/
//
// End of "$Id: Fl_Tree_Prefs.H 6956 2009-12-08 08:06:44Z greg.ercolano $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget.H 6912 2009-10-02 19:08:55Z matt $"
// "$Id: Fl_Widget.H 7661 2010-07-01 15:01:49Z manolo $"
//
// Widget header file for the Fast Light Tool Kit (FLTK).
//
@@ -25,7 +25,7 @@
// http://www.fltk.org/str.php
//
/* \file
/** \file
Fl_Widget, Fl_Label classes . */
#ifndef Fl_Widget_H
@@ -49,7 +49,6 @@ typedef void (Fl_Callback0)(Fl_Widget*);
/** Callback type definition passing the widget and a long data value */
typedef void (Fl_Callback1)(Fl_Widget*, long);
/** This struct stores all information for a text or mixed graphics label.
\todo For FLTK 1.3, the Fl_Label type will become a widget by itself. That way
@@ -64,14 +63,17 @@ struct FL_EXPORT Fl_Label {
Fl_Image* image;
/** optional image for a deactivated label */
Fl_Image* deimage;
/** type of label. \see Fl_Labeltype */
uchar type;
/** label font used in text */
Fl_Font font;
/** size of label font */
Fl_Fontsize size;
/** text color */
Fl_Color color;
/** alignment of label */
Fl_Align align_;
/** type of label. \see Fl_Labeltype */
uchar type;
/** Draws the label aligned to the given box */
void draw(int,int,int,int, Fl_Align) const ;
void measure(int &w, int &h) const ;
@@ -104,7 +106,6 @@ class FL_EXPORT Fl_Widget {
uchar type_;
uchar damage_;
uchar box_;
Fl_Align align_:8;
uchar when_;
const char *tooltip_;
@@ -126,7 +127,7 @@ protected:
\param[in] w, h size of the widget in pixels
\param[in] label optional text for the widget label
*/
Fl_Widget(int x, int y, int w, int h, Fl_CString label=0L);
Fl_Widget(int x, int y, int w, int h, const char *label=0L);
/** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
void x(int v) {x_ = v;}
@@ -171,6 +172,7 @@ protected:
void draw_box() const;
void draw_box(Fl_Boxtype t, Fl_Color c) const;
void draw_box(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color c) const;
void draw_backdrop() const;
/** draws a focus rectangle around the widget */
void draw_focus() {draw_focus(box(),x(),y(),w(),h());}
void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const;
@@ -331,7 +333,7 @@ public:
Fl_Align is (typedef'd to be) "unsigned" (int), but Fl_Widget's
"align_" member variable is a bit field of 8 bits only !
*/
Fl_Align align() const {return align_;}
Fl_Align align() const {return label_.align_;}
/** Sets the label alignment.
This controls how the label is displayed next to or inside the widget.
@@ -340,7 +342,7 @@ public:
\param[in] alignment new label alignment
\see align(), Fl_Align
*/
void align(Fl_Align alignment) {align_ = alignment;}
void align(Fl_Align alignment) {label_.align_ = alignment;}
/** Gets the box type of the widget.
\return the current box type
@@ -402,7 +404,7 @@ public:
/** Gets the current label text.
\return a pointer to the current label text
\see label(Fl_CString), copy_label(Fl_CString)
\see label(const char *), copy_label(const char *)
*/
const char* label() const {return label_.value;}
@@ -428,10 +430,10 @@ public:
\param[in] new_label the new label text
\see label()
*/
void copy_label(Fl_CString new_label);
void copy_label(const char *new_label);
/** Shortcut to set the label text and type in one call.
\see label(FL_CString), labeltype(Fl_Labeltype)
\see label(const char *), labeltype(Fl_Labeltype)
*/
void label(Fl_Labeltype a, const char* b) {label_.type = a; label_.value = b;}
@@ -498,6 +500,7 @@ public:
\return the current image
*/
Fl_Image* image() {return label_.image;}
const Fl_Image* image() const {return label_.image;}
/** Sets the image to use as part of the widget label.
This image is used when drawing the widget in the active state.
@@ -516,6 +519,7 @@ public:
\return the current image for the deactivated widget
*/
Fl_Image* deimage() {return label_.deimage;}
const Fl_Image* deimage() const {return label_.deimage;}
/** Sets the image to use as part of the widget label.
This image is used when drawing the widget in the inactive state.
@@ -844,7 +848,7 @@ public:
/** Internal use only. */
int test_shortcut();
/** Internal use only. */
static Fl_Shortcut label_shortcut(const char *t);
static unsigned int label_shortcut(const char *t);
/** Internal use only. */
static int test_shortcut(const char*);
@@ -925,6 +929,29 @@ public:
*/
Fl_Window* window() const ;
/** Returns an Fl_Group pointer if this widget is an Fl_Group.
\retval NULL if this widget is not derived from Fl_Group.
\note This method is provided to avoid dynamic_cast.
\todo More documentation ...
*/
virtual Fl_Group* as_group() {return 0;}
/** Returns an Fl_Window pointer if this widget is an Fl_Window.
\retval NULL if this widget is not derived from Fl_Window.
\note This method is provided to avoid dynamic_cast.
\todo More documentation ...
*/
virtual Fl_Window* as_window() {return 0;}
/** Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window.
\retval NULL if this widget is not derived from Fl_Gl_Window.
\note This method is provided to avoid dynamic_cast.
\todo More documentation ...
*/
virtual class Fl_Gl_Window* as_gl_window() {return 0;}
/** For back compatibility only.
\deprecated Use selection_color() instead.
*/
@@ -946,5 +973,5 @@ public:
#endif
//
// End of "$Id: Fl_Widget.H 6912 2009-10-02 19:08:55Z matt $".
// End of "$Id: Fl_Widget.H 7661 2010-07-01 15:01:49Z manolo $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Window.H 6907 2009-09-28 14:34:52Z matt $"
// "$Id: Fl_Window.H 7280 2010-03-16 22:51:31Z matt $"
//
// Window header file for the Fast Light Tool Kit (FLTK).
//
@@ -43,15 +43,17 @@ class Fl_X;
window, with a border and title and all the window management controls,
or a "subwindow" inside a window. This is controlled by whether or not
the window has a parent().
<P>Once you create a window, you usually add children Fl_Widget
's to it by using window-&gt;add(child) for each new widget. See Fl_Group for more information
on how to add and remove children. </P>
<P>There are several subclasses of Fl_Window that provide
double-buffering, overlay, menu, and OpenGL support. </P>
<P>The window's callback is done if the user tries to close a window
using the window manager and
Fl::modal() is zero or equal to the window. Fl_Window
has a default callback that calls Fl_Window::hide().
Once you create a window, you usually add children Fl_Widget
's to it by using window->add(child) for each new widget.
See Fl_Group for more information on how to add and remove children.
There are several subclasses of Fl_Window that provide
double-buffering, overlay, menu, and OpenGL support.
The window's callback is done if the user tries to close a window
using the window manager and Fl::modal() is zero or equal to the
window. Fl_Window has a default callback that calls Fl_Window::hide().
*/
class FL_EXPORT Fl_Window : public Fl_Group {
@@ -77,20 +79,42 @@ class FL_EXPORT Fl_Window : public Fl_Group {
protected:
/** Stores the last window that was made current. See current() const */
/** Stores the last window that was made current. See current() const */
static Fl_Window *current_;
virtual void draw();
/** Forces the window to be drawn, this window is also made current and calls draw(). */
virtual void flush();
/**
Sets an internal flag that tells FLTK and the window manager to
honor position requests.
This is used internally and should not be needed by user code.
\param[in] force 1 to set the FORCE_POSITION flag, 0 to clear it
*/
void force_position(int force) {
if (force) set_flag(FORCE_POSITION);
else clear_flag(FORCE_POSITION);
}
/**
Returns the internal state of the window's FORCE_POSITION flag.
\retval 1 if flag is set
\retval 0 otherwise
\see force_position(int)
*/
int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
public:
/**
Creates a window from the given size and title.
If Fl_Group::current() is not NULL, the window is created as a
subwindow of the parent window.</p>
subwindow of the parent window.
<p>The first form of the constructor creates a top-level window
The first form of the constructor creates a top-level window
and asks the window manager to position the window. The second
form of the constructor either creates a subwindow or a
top-level window at the specified location (x,y) , subject to window
@@ -99,28 +123,31 @@ public:
or allow the user to pick a location. Use position(x,y)
or hotspot() before calling show() to request a
position on the screen. See Fl_Window::resize()
for some more details on positioning windows.</p>
for some more details on positioning windows.
<p>Top-level windows initially have visible() set to 0
Top-level windows initially have visible() set to 0
and parent() set to NULL. Subwindows initially
have visible() set to 1 and parent() set to
the parent window pointer.</p>
the parent window pointer.
<P>Fl_Widget::box() defaults to FL_FLAT_BOX. If you
plan to completely fill the window with children widgets you should
Fl_Widget::box() defaults to FL_FLAT_BOX. If you plan to
completely fill the window with children widgets you should
change this to FL_NO_BOX. If you turn the window border off
you may want to change this to FL_UP_BOX.
\see Fl_Window(int x, int y, int w, int h, const char* title = 0)
*/
Fl_Window(int w, int h, const char* title= 0);
/** Creates a window from the given position, size and title.
See Fl_Window::Fl_Window(int w, int h, const char *title = 0)
/** Creates a window from the given position, size and title.
\see Fl_Window::Fl_Window(int w, int h, const char *title = 0)
*/
Fl_Window(int x, int y, int w, int h, const char* title = 0);
/**
The destructor <I>also deletes all the children</I>. This allows a
whole tree to be deleted at once, without having to keep a pointer to
all the children in the user code. A kludge has been done so the
Fl_Window and all of it's children can be automatic (local)
Fl_Window and all of its children can be automatic (local)
variables, but you must declare the Fl_Window <I>first</I> so
that it is destroyed last.
*/
@@ -129,16 +156,16 @@ public:
virtual int handle(int);
/**
Changes the size and position of the window. If shown() is
true, these changes are communicated to the window server (which may
Changes the size and position of the window. If shown() is true,
these changes are communicated to the window server (which may
refuse that size and cause a further resize). If shown() is
false, the size and position are used when show() is called.
See Fl_Group for the effect
of resizing on the child widgets.
<P>You can also call the Fl_Widget methods size(x,y)
and position(w,h), which are inline wrappers for this virtual
function. </P>
<P>A top-level window can not force, but merely suggest a position and
See Fl_Group for the effect of resizing on the child widgets.
You can also call the Fl_Widget methods size(x,y) and position(w,h),
which are inline wrappers for this virtual function.
A top-level window can not force, but merely suggest a position and
size to the operating system. The window manager may not be willing or
able to display a window at the desired position or with the given
dimensions. It is up to the application developer to verify window
@@ -146,21 +173,21 @@ public:
*/
virtual void resize(int,int,int,int);
/**
Gets or sets whether or not the window manager border is around the
window. The default value is true. border(n) can be used to
turn the border on and off, and returns non-zero if the value has been
changed. <I>Under most X window managers this does not work after
show() has been called, although SGI's 4DWM does work.</I>
Sets whether or not the window manager border is around the
window. The default value is true. void border(int) can be
used to turn the border on and off. <I>Under most X window
managers this does not work after show() has been called,
although SGI's 4DWM does work.</I>
*/
void border(int b);
/**
Fast inline function to turn the border
Fast inline function to turn the window manager border
off. It only works before show() is called.
*/
void clear_border() {set_flag(NOBORDER);}
/** See int Fl_Window::border(int) */
/** See void Fl_Window::border(int) */
unsigned int border() const {return !(flags() & NOBORDER);}
/** Activate the flags NOBORDER|FL_OVERRIDE */
/** Activates the flags NOBORDER|FL_OVERRIDE */
void set_override() {set_flag(NOBORDER|OVERRIDE);}
/** Returns non zero if FL_OVERRIDE flag is set, 0 otherwise. */
unsigned int override() const { return flags()&OVERRIDE; }
@@ -170,8 +197,7 @@ public:
remain on top of the other windows (if the X window manager supports
the "transient for" property). Several modal windows may be shown at
once, in which case only the last one shown gets events. You can see
which window (if any) is modal by calling
Fl::modal().
which window (if any) is modal by calling Fl::modal().
*/
void set_modal() {set_flag(MODAL);}
/** Returns true if this window is modal. */
@@ -188,14 +214,14 @@ public:
/**
Marks the window as a menu window.
This is intended for internal use, but it can also be used if you
write your own menu handling. However, this is not recommended.
This flag is used for correct "parenting" of windows in communication
with the windowing system. Modern X window managers can use different
flags to distinguish menu and tooltip windows from normal windows.
This must be called before the window is shown and cannot be changed
later.
*/
@@ -206,14 +232,14 @@ public:
/**
Marks the window as a tooltip window.
This is intended for internal use, but it can also be used if you
write your own tooltip handling. However, this is not recommended.
This flag is used for correct "parenting" of windows in communication
with the windowing system. Modern X window managers can use different
flags to distinguish menu and tooltip windows from normal windows.
This must be called before the window is shown and cannot be changed
later.
@@ -226,8 +252,8 @@ public:
unsigned int tooltip_window() const {return flags() & TOOLTIP_WINDOW;}
/**
Position the window so that the mouse is pointing at the
given position, or at the center of the given widget, which may be the
Positions the window so that the mouse is pointing at the given
position, or at the center of the given widget, which may be the
window itself. If the optional offscreen parameter is
non-zero, then the window is allowed to extend off the screen (this
does not work with some X window managers). \see position()
@@ -237,43 +263,49 @@ public:
void hotspot(const Fl_Widget*, int offscreen = 0);
/** See void Fl_Window::hotspot(int x, int y, int offscreen = 0) */
void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);}
/**
Undoes the effect of a previous resize() or show()
so that the next time show() is called the window manager is
free to position the window.
Undoes the effect of a previous resize() or show() so that the next time
show() is called the window manager is free to position the window.
This is for Forms compatibility only.
\deprecated please use force_position(0) instead
*/
void free_position() {clear_flag(FORCE_POSITION);}
/**
Set the allowable range the user can resize this window to. This only
works for top-level windows.
Sets the allowable range the user can resize this window to.
This only works for top-level windows.
<UL>
<LI>minw and minh are the smallest the window can
be. Either value must be greater than 0.</LI>
<LI>maxw and maxh are the largest the window can be.
If either is <I>equal</I> to the minimum then you cannot resize in
that direction. If either is zero then FLTK picks a maximum size in
that direction such that the window will fill the screen. </LI>
<LI>dw and dh are size increments. The window will
be constrained to widths of minw + N * dw, where N
is any non-negative integer. If these are less or equal to 1 they
are ignored. (this is ignored on WIN32)</LI>
<LI>aspect is a flag that indicates that the window should
preserve it's aspect ratio. This only works if both the maximum and
minimum have the same aspect ratio. (ignored on WIN32 and by many X
window managers)</LI>
<LI>minw and minh are the smallest the window can be.
Either value must be greater than 0.</LI>
<LI>maxw and maxh are the largest the window can be. If either is
<I>equal</I> to the minimum then you cannot resize in that direction.
If either is zero then FLTK picks a maximum size in that direction
such that the window will fill the screen.</LI>
<LI>dw and dh are size increments. The window will be constrained
to widths of minw + N * dw, where N is any non-negative integer.
If these are less or equal to 1 they are ignored (this is ignored
on WIN32).</LI>
<LI>aspect is a flag that indicates that the window should preserve its
aspect ratio. This only works if both the maximum and minimum have
the same aspect ratio (ignored on WIN32 and by many X window managers).
</LI>
</UL>
If this function is not called, FLTK tries to figure out the range
from the setting of resizable():
<UL>
<LI>If resizable() is NULL (this is the default)
then the window cannot be resized and the resize border and max-size
control will not be displayed for the window. </LI>
<LI>If either dimension of resizable() is less than 100,
then that is considered the minimum size. Otherwise the
resizable() has a minimum size of 100. </LI>
<LI>If either dimension of resizable() is zero, then that is
also the maximum size (so the window cannot resize in that direction). </LI>
<LI>If resizable() is NULL (this is the default) then the window cannot
be resized and the resize border and max-size control will not be
displayed for the window.</LI>
<LI>If either dimension of resizable() is less than 100, then that is
considered the minimum size. Otherwise the resizable() has a minimum
size of 100.</LI>
<LI>If either dimension of resizable() is zero, then that is also the
maximum size (so the window cannot resize in that direction).</LI>
</UL>
It is undefined what happens if the current size does not fit in the
constraints passed to size_range().
*/
@@ -284,11 +316,11 @@ public:
const char* label() const {return Fl_Widget::label();}
/** See void Fl_Window::iconlabel(const char*) */
const char* iconlabel() const {return iconlabel_;}
/** Sets the window title bar label. */
/** Sets the window title bar label. */
void label(const char*);
/** Sets the icon label. */
void iconlabel(const char*);
/** Gets or sets the icon label. */
/** Sets the icon label. */
void label(const char* label, const char* iconlabel); // platform dependent
void copy_label(const char* a);
/** See void Fl_Window::xclass(const char*) */
@@ -301,36 +333,38 @@ public:
the second one if the first is 'x'. Thus "foo" turns into "foo, Foo",
and "xprog.1" turns into "xprog, XProg".</I> This only works if called <I>
before</I> calling show().
<P>Under Microsoft Windows this string is used as the name of the
Under Microsoft Windows this string is used as the name of the
WNDCLASS structure, though it is not clear if this can have any
visible effect. The passed pointer is stored unchanged. The string
is not copied.
*/
void xclass(const char* c) {xclass_ = c;}
/** Gets the current icon window target dependent data */
/** Gets the current icon window target dependent data. */
const void* icon() const {return icon_;}
/** Sets the current icon window target dependent data */
/** Sets the current icon window target dependent data. */
void icon(const void * ic) {icon_ = ic;}
/**
Returns non-zero if show() has been called (but not hide()
). You can tell if a window is iconified with (w-&gt;shown()
&!w-&gt;visible()).
). You can tell if a window is iconified with (w->shown()
&& !w->visible()).
*/
int shown() {return i != 0;}
/**
Put the window on the screen. Usually this has the side effect of
opening the display. The second form is used for top-level
windows and allow standard arguments to be parsed from the
Puts the window on the screen. Usually (on X) this has the side
effect of opening the display. The second form is used for top-level
windows and allows standard arguments to be parsed from the
command-line.
<P>If the window is already shown then it is restored and raised to the
If the window is already shown then it is restored and raised to the
top. This is really convenient because your program can call show()
at any time, even if the window is already up. It also means that
show() serves the purpose of raise() in other toolkits.
*/
virtual void show();
/**
Remove the window from the screen. If the window is already hidden or
Removes the window from the screen. If the window is already hidden or
has not been shown then this does nothing and is harmless.
*/
virtual void hide();
@@ -353,11 +387,14 @@ public:
Iconifies the window. If you call this when shown() is false
it will show() it as an icon. If the window is already
iconified this does nothing.
<P>Call show() to restore the window. </P>
<P>When a window is iconified/restored (either by these calls or by the
Call show() to restore the window.
When a window is iconified/restored (either by these calls or by the
user) the handle() method is called with FL_HIDE and
FL_SHOW events and visible() is turned on and off. </P>
<P>There is no way to control what is drawn in the icon except with the
FL_SHOW events and visible() is turned on and off.
There is no way to control what is drawn in the icon except with the
string passed to Fl_Window::xclass(). You should not rely on
window managers displaying the icons.
*/
@@ -368,28 +405,37 @@ public:
static Fl_Window *current();
/**
Sets things up so that the drawing functions in &lt;FL/fl_draw.H&gt; will go into this
window. This is useful for incremental update of windows, such as in an
idle callback, which will make your program behave much better if it
draws a slow graphic. <B>Danger: incremental update is very hard to
Sets things up so that the drawing functions in <FL/fl_draw.H> will go
into this window. This is useful for incremental update of windows, such
as in an idle callback, which will make your program behave much better
if it draws a slow graphic. <B>Danger: incremental update is very hard to
debug and maintain!</B>
<P>This method only works for the Fl_Window and
Fl_Gl_Window derived classes.
This method only works for the Fl_Window and Fl_Gl_Window derived classes.
*/
void make_current();
/** Returns an Fl_Window pointer if this widget is an Fl_Window.
\retval NULL if this widget is not derived from Fl_Window.
\note This method is provided to avoid dynamic_cast.
\todo More documentation ...
*/
virtual Fl_Window* as_window() { return this; }
// for back-compatibility only:
/**
Changes the cursor for this window. This always calls the system, if
you are changing the cursor a lot you may want to keep track of how
you set it in a static varaible and call this only if the new cursor
is different.
you set it in a static variable and call this only if the new cursor
is different.
<P>The type Fl_Cursor is an enumeration defined in &lt;Enumerations.H&gt;.
The type Fl_Cursor is an enumeration defined in <FL/Enumerations.H>.
(Under X you can get any XC_cursor value by passing
Fl_Cursor((XC_foo/2)+1)). The colors only work on X, they are
not implemented on WIN32.
<P> For back compatibility only.
For back compatibility only.
*/
void cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE); // platform dependent
void default_cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE);
@@ -400,5 +446,5 @@ public:
#endif
//
// End of "$Id: Fl_Window.H 6907 2009-09-28 14:34:52Z matt $".
// End of "$Id: Fl_Window.H 7280 2010-03-16 22:51:31Z matt $".
//

View File

@@ -1,4 +1,4 @@
/* "$Id: $"
/* "$Id: Xutf8.h 6942 2009-11-18 12:22:51Z AlbrechtS $"
*
* Author: Jean-Marc Lienher ( http://oksid.ch )
* Copyright 2000-2003 by O'ksi'D.
@@ -172,5 +172,5 @@ XUtf8Toupper(
#endif
/*
* End of "$Id: $".
* End of "$Id: Xutf8.h 6942 2009-11-18 12:22:51Z AlbrechtS $".
*/

View File

@@ -1,5 +1,5 @@
//
// "$Id: dirent.h 6614 2009-01-01 16:11:32Z matt $"
// "$Id: dirent.h 7504 2010-04-14 20:17:44Z matt $"
//
// Directory header file for the Fast Light Tool Kit (FLTK).
//
@@ -25,9 +25,10 @@
// http://www.fltk.org/str.php
//
// this file is for back-compatability only
#include "filename.H"
//
// End of "$Id: dirent.h 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: dirent.h 7504 2010-04-14 20:17:44Z matt $".
//

View File

@@ -1,5 +1,5 @@
/*
* "$Id: filename.H 6716 2009-03-24 01:40:44Z fabien $"
* "$Id: filename.H 7504 2010-04-14 20:17:44Z matt $"
*
* Filename header file for the Fast Light Tool Kit (FLTK).
*
@@ -25,6 +25,12 @@
* http://www.fltk.org/str.php
*/
// Xcode on OS X includes files by recursing down into directories.
// This code catches the cycle and directly includes the required file.
#ifdef fl_dirent_h_cyclic_include
# include "/usr/include/dirent.h"
#endif
#ifndef FL_FILENAME_H
# define FL_FILENAME_H
@@ -34,9 +40,23 @@
@{ */
# define FL_PATH_MAX 256 /**< all path buffers should use this length */
/** Gets the file name from a path. \return a pointer to the char after the last slash, or to \p filename if there is none. */
/** Gets the file name from a path.
Similar to basename(3), exceptions shown below.
\code
#include <FL/filename.H>
[..]
const char *out;
out = fl_filename_name("/usr/lib"); // out="lib"
out = fl_filename_name("/usr/"); // out="" (basename(3) returns "usr" instead)
out = fl_filename_name("/usr"); // out="usr"
out = fl_filename_name("/"); // out="" (basename(3) returns "/" instead)
out = fl_filename_name("."); // out="."
out = fl_filename_name(".."); // out=".."
\endcode
\return a pointer to the char after the last slash, or to \p filename if there is none.
*/
FL_EXPORT const char *fl_filename_name(const char * filename);
FL_EXPORT const char *fl_filename_ext(const char *);
FL_EXPORT const char *fl_filename_ext(const char *buf);
FL_EXPORT char *fl_filename_setext(char *to, int tolen, const char *ext);
FL_EXPORT int fl_filename_expand(char *to, int tolen, const char *from);
FL_EXPORT int fl_filename_absolute(char *to, int tolen, const char *from);
@@ -60,17 +80,6 @@ inline int fl_filename_relative(char *to, const char *from) { return fl_filename
struct dirent {char d_name[1];};
# elif defined(__APPLE__) && defined(__PROJECTBUILDER__)
/* Apple's ProjectBuilder has the nasty habit of including recursively
* down the file tree. To avoid re-including <FL/dirent.h> we must
* directly include the systems math file. (Plus, I could not find a
* predefined macro for ProjectBuilder builds, so we have to define it
* in the project)
*/
# include <sys/types.h>
# include "/usr/include/dirent.h"
# elif defined(__WATCOMC__)
# include <sys/types.h>
# include <direct.h>
@@ -91,7 +100,9 @@ struct dirent {char d_name[1];};
* It would be best to create a <dirent.h> file that does this...
*/
# include <sys/types.h>
# define fl_dirent_h_cyclic_include
# include <dirent.h>
# undef fl_dirent_h_cyclic_include
# endif
# if defined (__cplusplus)
@@ -161,5 +172,5 @@ int _fl_filename_isdir_quick(const char *name);
/** @} */
/*
* End of "$Id: filename.H 6716 2009-03-24 01:40:44Z fabien $".
* End of "$Id: filename.H 7504 2010-04-14 20:17:44Z matt $".
*/

View File

@@ -1,5 +1,5 @@
//
// "$Id: fl_draw.H 6878 2009-09-17 22:12:24Z matt $"
// "$Id: fl_draw.H 7659 2010-07-01 13:21:32Z manolo $"
//
// Portable drawing function header file for the Fast Light Tool Kit (FLTK).
//
@@ -35,6 +35,7 @@
#include "Enumerations.H" // for the color names
#include "Fl_Window.H" // for fl_set_spot()
#include "Fl_Device.H"
// Image class...
class Fl_Image;
@@ -45,11 +46,32 @@ FL_EXPORT extern char fl_draw_shortcut;
/** \addtogroup fl_attributes
@{
*/
// Colors:
FL_EXPORT void fl_color(Fl_Color i); // select indexed color
/**
Sets the color for all subsequent drawing operations.
For colormapped displays, a color cell will be allocated out of
\p fl_colormap the first time you use a color. If the colormap fills up
then a least-squares algorithm is used to find the closest color.
If no valid graphical context (fl_gc) is available,
the foreground is not set for the current window.
\param[in] c color
*/
inline void fl_color(Fl_Color c) {fl_graphics_driver->color(c); }; // select indexed color
/** for back compatibility - use fl_color(Fl_Color c) instead */
inline void fl_color(int c) {fl_color((Fl_Color)c);}
FL_EXPORT void fl_color(uchar r, uchar g, uchar b); // select actual color
/**
Set the color for all subsequent drawing operations.
The closest possible match to the RGB color is used.
The RGB color is used directly on TrueColor displays.
For colormap visuals the nearest index in the gray
ramp or color cube is used.
If no valid graphical context (fl_gc) is available,
the foreground is not set for the current window.
\param[in] r,g,b color components
*/
inline void fl_color(uchar r, uchar g, uchar b) {fl_graphics_driver->color(r,g,b); }; // select actual color
/** \brief The current color */
extern FL_EXPORT Fl_Color fl_color_;
/**
Returns the last fl_color() that was set.
@@ -62,19 +84,103 @@ inline Fl_Color fl_color() {return fl_color_;}
@{
*/
// clip:
FL_EXPORT void fl_push_clip(int x, int y, int w, int h);
/**
Intersects the current clip region with a rectangle and pushes this
new region onto the stack.
\param[in] x,y,w,h position and size
*/
inline void fl_push_clip(int x, int y, int w, int h) {fl_graphics_driver->push_clip(x,y,w,h); };
/** The fl_clip() name is deprecated and will be removed from future releases */
#define fl_clip fl_push_clip
FL_EXPORT void fl_push_no_clip();
FL_EXPORT void fl_pop_clip();
FL_EXPORT int fl_not_clipped(int x, int y, int w, int h);
FL_EXPORT int fl_clip_box(int, int, int, int, int& x, int& y, int& w, int& h);
/**
Pushes an empty clip region onto the stack so nothing will be clipped.
*/
inline void fl_push_no_clip() {fl_graphics_driver->push_no_clip(); };
/**
Restores the previous clip region.
You must call fl_pop_clip() once for every time you call fl_push_clip().
Unpredictable results may occur if the clip stack is not empty when
you return to FLTK.
*/
inline void fl_pop_clip() {fl_graphics_driver->pop_clip(); };
/**
Does the rectangle intersect the current clip region?
\param[in] x,y,w,h position and size of rectangle
\returns non-zero if any of the rectangle intersects the current clip
region. If this returns 0 you don't have to draw the object.
\note
Under X this returns 2 if the rectangle is partially clipped,
and 1 if it is entirely inside the clip region.
*/
inline int fl_not_clipped(int x, int y, int w, int h) {return fl_graphics_driver->not_clipped(x,y,w,h); };
/**
Intersects the rectangle with the current clip region and returns the
bounding box of the result.
Returns non-zero if the resulting rectangle is different to the original.
This can be used to limit the necessary drawing to a rectangle.
\p W and \p H are set to zero if the rectangle is completely outside
the region.
\param[in] x,y,w,h position and size of rectangle
\param[out] X,Y,W,H position and size of resulting bounding box.
\p W and \p H are set to zero if the rectangle is
completely outside the region.
\returns Non-zero if the resulting rectangle is different to the original.
*/
inline int fl_clip_box(int x , int y, int w, int h, int& X, int& Y, int& W, int& H)
{return fl_graphics_driver->clip_box(x,y,w,h,X,Y,W,H); };
/** Undoes any clobbering of clip done by your program */
extern void fl_restore_clip();
/**
Replaces the top of the clipping stack with a clipping region of any shape.
Fl_Region is an operating system specific type.
\param[in] r clipping region
*/
FL_EXPORT void fl_clip_region(Fl_Region r);
/**
returns the current clipping region.
*/
extern Fl_Region fl_clip_region();
// points:
FL_EXPORT void fl_point(int x, int y);
/**
Draws a single pixel at the given coordinates
*/
inline void fl_point(int x, int y) { fl_graphics_driver->point(x,y); };
// line type:
FL_EXPORT void fl_line_style(int style, int width=0, char* dashes=0);
/**
Sets how to draw lines (the "pen").
If you change this it is your responsibility to set it back to the default
using \c fl_line_style(0).
\param[in] style A bitmask which is a bitwise-OR of a line style, a cap
style, and a join style. If you don't specify a dash type you
will get a solid line. If you don't specify a cap or join type
you will get a system-defined default of whatever value is
fastest.
\param[in] width The thickness of the lines in pixels. Zero results in the
system defined default, which on both X and Windows is somewhat
different and nicer than 1.
\param[in] dashes A pointer to an array of dash lengths, measured in pixels.
The first location is how long to draw a solid portion, the next
is how long to draw the gap, then the solid, etc. It is terminated
with a zero-length entry. A \c NULL pointer or a zero-length
array results in a solid line. Odd array sizes are not supported
and result in undefined behavior.
\note Because of how line styles are implemented on Win32 systems,
you \e must set the line style \e after setting the drawing
color. If you set the color after the line style you will lose
the line style settings.
\note The \p dashes array does not work under Windows 95, 98 or Me,
since those operating systems do not support complex line styles.
*/
inline void fl_line_style(int style, int width=0, char* dashes=0) {fl_graphics_driver->line_style(style,width,dashes); };
enum {
FL_SOLID = 0, ///< line style: <tt>___________</tt>
FL_DASH = 1, ///< line style: <tt>_ _ _ _ _ _</tt>
@@ -92,11 +198,19 @@ enum {
};
// rectangles tweaked to exactly fill the pixel rectangle:
FL_EXPORT void fl_rect(int x, int y, int w, int h);
/** Draws a 1-pixel border \e inside the given bounding box */
/**
Draws a 1-pixel border \e inside the given bounding box.
This function is meant for quick drawing of simple boxes. The behavior is
undefined for line widths that are not 1.
*/
inline void fl_rect(int x, int y, int w, int h) { fl_graphics_driver->rect(x,y,w,h); };
/** Draws with passed color a 1-pixel border \e inside the given bounding box */
inline void fl_rect(int x, int y, int w, int h, Fl_Color c) {fl_color(c); fl_rect(x,y,w,h);}
FL_EXPORT void fl_rectf(int x, int y, int w, int h);
/** Colors a rectangle that exactly fills the given bounding box */
/** Colors with current color a rectangle that exactly fills the given bounding box */
inline void fl_rectf(int x, int y, int w, int h) { fl_graphics_driver->rectf(x,y,w,h); };
/** Colors with passsed color a rectangle that exactly fills the given bounding box */
inline void fl_rectf(int x, int y, int w, int h, Fl_Color c) {fl_color(c); fl_rectf(x,y,w,h);}
/**
@@ -109,30 +223,104 @@ inline void fl_rectf(int x, int y, int w, int h, Fl_Color c) {fl_color(c); fl_re
FL_EXPORT void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b);
// line segments:
FL_EXPORT void fl_line(int x, int y, int x1, int y1);
FL_EXPORT void fl_line(int x, int y, int x1, int y1, int x2, int y2);
/**
Draws a line from (x,y) to (x1,y1)
*/
inline void fl_line(int x, int y, int x1, int y1) {fl_graphics_driver->line(x,y,x1,y1); };
/**
Draws a line from (x,y) to (x1,y1) and another from (x1,y1) to (x2,y2)
*/
inline void fl_line(int x, int y, int x1, int y1, int x2, int y2) {fl_graphics_driver->line(x,y,x1,y1,x2,y2); };
// closed line segments:
FL_EXPORT void fl_loop(int x, int y, int x1, int y1, int x2, int y2);
FL_EXPORT void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3);
/**
Outlines a 3-sided polygon with lines
*/
inline void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {fl_graphics_driver->loop(x,y,x1,y1,x2,y2); };
/**
Outlines a 4-sided polygon with lines
*/
inline void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
{fl_graphics_driver->loop(x,y,x1,y1,x2,y2,x3,y3); };
// filled polygons
FL_EXPORT void fl_polygon(int x, int y, int x1, int y1, int x2, int y2);
FL_EXPORT void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3);
/**
Fills a 3-sided polygon. The polygon must be convex.
*/
inline void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {fl_graphics_driver->polygon(x,y,x1,y1,x2,y2); };
/**
Fills a 4-sided polygon. The polygon must be convex.
*/
inline void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
{ fl_graphics_driver->polygon(x,y,x1,y1,x2,y2,x3,y3); };
// draw rectilinear lines, horizontal segment first:
FL_EXPORT void fl_xyline(int x, int y, int x1);
FL_EXPORT void fl_xyline(int x, int y, int x1, int y2);
FL_EXPORT void fl_xyline(int x, int y, int x1, int y2, int x3);
/**
Draws a horizontal line from (x,y) to (x1,y)
*/
inline void fl_xyline(int x, int y, int x1) {fl_graphics_driver->xyline(x,y,x1);};
/**
Draws a horizontal line from (x,y) to (x1,y), then vertical from (x1,y) to (x1,y2)
*/
inline void fl_xyline(int x, int y, int x1, int y2) {fl_graphics_driver->xyline(x,y,x1,y2);};
/**
Draws a horizontal line from (x,y) to (x1,y), then a vertical from (x1,y) to (x1,y2)
and then another horizontal from (x1,y2) to (x3,y2)
*/
inline void fl_xyline(int x, int y, int x1, int y2, int x3) {fl_graphics_driver->xyline(x,y,x1,y2,x3);};
// draw rectilinear lines, vertical segment first:
FL_EXPORT void fl_yxline(int x, int y, int y1);
FL_EXPORT void fl_yxline(int x, int y, int y1, int x2);
FL_EXPORT void fl_yxline(int x, int y, int y1, int x2, int y3);
/**
Draws a vertical line from (x,y) to (x,y1)
*/
inline void fl_yxline(int x, int y, int y1) {fl_graphics_driver->yxline(x,y,y1);};
/**
Draws a vertical line from (x,y) to (x,y1), then a horizontal from (x,y1) to (x2,y1)
*/
inline void fl_yxline(int x, int y, int y1, int x2) {fl_graphics_driver->yxline(x,y,y1,x2);};
/**
Draws a vertical line from (x,y) to (x,y1) then a horizontal from (x,y1)
to (x2,y1), then another vertical from (x2,y1) to (x2,y3)
*/
inline void fl_yxline(int x, int y, int y1, int x2, int y3) {fl_graphics_driver->yxline(x,y,y1,x2,y3);};
// circular lines and pie slices (code in fl_arci.C):
FL_EXPORT void fl_arc(int x, int y, int w, int h, double a1, double a2);
FL_EXPORT void fl_pie(int x, int y, int w, int h, double a1, double a2);
/**
Draw ellipse sections using integer coordinates.
These functions match the rather limited circle drawing code provided by X
and WIN32. The advantage over using fl_arc with floating point coordinates
is that they are faster because they often use the hardware, and they draw
much nicer small circles, since the small sizes are often hard-coded bitmaps.
If a complete circle is drawn it will fit inside the passed bounding box.
The two angles are measured in degrees counterclockwise from 3 o'clock and
are the starting and ending angle of the arc, \p a2 must be greater or equal
to \p a1.
fl_arc() draws a series of lines to approximate the arc. Notice that the
integer version of fl_arc() has a different number of arguments than the
double version fl_arc(double x, double y, double r, double start, double end)
\param[in] x,y,w,h bounding box of complete circle
\param[in] a1,a2 start and end angles of arc measured in degrees
counter-clockwise from 3 o'clock. \p a2 must be greater
than or equal to \p a1.
*/
inline void fl_arc(int x, int y, int w, int h, double a1, double a2) {fl_graphics_driver->arc(x,y,w,h,a1,a2); };
/**
Draw filled ellipse sections using integer coordinates.
Like fl_arc(), but fl_pie() draws a filled-in pie slice.
This slice may extend outside the line drawn by fl_arc();
to avoid this use w - 1 and h - 1.
\param[in] x,y,w,h bounding box of complete circle
\param[in] a1,a2 start and end angles of arc measured in degrees
counter-clockwise from 3 o'clock. \p a2 must be greater
than or equal to \p a1.
*/
inline void fl_pie(int x, int y, int w, int h, double a1, double a2) {fl_graphics_driver->pie(x,y,w,h,a1,a2); };
/** fl_chord declaration is a place holder - the function does not yet exist */
FL_EXPORT void fl_chord(int x, int y, int w, int h, double a1, double a2); // nyi
@@ -144,32 +332,113 @@ FL_EXPORT void fl_scale(double x);
FL_EXPORT void fl_translate(double x, double y);
FL_EXPORT void fl_rotate(double d);
FL_EXPORT void fl_mult_matrix(double a, double b, double c, double d, double x,double y);
FL_EXPORT void fl_begin_points();
FL_EXPORT void fl_begin_line();
FL_EXPORT void fl_begin_loop();
FL_EXPORT void fl_begin_polygon();
FL_EXPORT void fl_vertex(double x, double y);
FL_EXPORT void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3);
FL_EXPORT void fl_arc(double x, double y, double r, double start, double a);
FL_EXPORT void fl_circle(double x, double y, double r);
FL_EXPORT void fl_end_points();
FL_EXPORT void fl_end_line();
FL_EXPORT void fl_end_loop();
FL_EXPORT void fl_end_polygon();
FL_EXPORT void fl_begin_complex_polygon();
FL_EXPORT void fl_gap();
FL_EXPORT void fl_end_complex_polygon();
/**
Starts drawing a list of points. Points are added to the list with fl_vertex()
*/
inline void fl_begin_points() {fl_graphics_driver->begin_points(); };
/**
Starts drawing a list of lines.
*/
inline void fl_begin_line() {fl_graphics_driver->begin_line(); };
/**
Starts drawing a closed sequence of lines.
*/
inline void fl_begin_loop() {fl_graphics_driver->begin_loop(); };
/**
Starts drawing a convex filled polygon.
*/
inline void fl_begin_polygon() {fl_graphics_driver->begin_polygon(); };
/**
Adds a single vertex to the current path.
\param[in] x,y coordinate
*/
inline void fl_vertex(double x, double y) {fl_graphics_driver->vertex(x,y); };
/**
Add a series of points on a Bezier curve to the path.
The curve ends (and two of the points) are at X0,Y0 and X3,Y3.
\param[in] X0,Y0 curve start point
\param[in] X1,Y1 curve control point
\param[in] X2,Y2 curve control point
\param[in] X3,Y3 curve end point
*/
inline void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3)
{fl_graphics_driver->curve(X0,Y0,X1,Y1,X2,Y2,X3,Y3); };
/**
Add a series of points to the current path on the arc of a circle; you
can get elliptical paths by using scale and rotate before calling fl_arc().
\param[in] x,y,r center and radius of circular arc
\param[in] start,end angles of start and end of arc measured in degrees
counter-clockwise from 3 o'clock. If \p end is less than \p start
then it draws the arc in a clockwise direction.
*/
inline void fl_arc(double x, double y, double r, double start, double end) {fl_graphics_driver->arc(x,y,r,start,end); };
/**
fl_circle() is equivalent to fl_arc(x,y,r,0,360), but may be faster.
It must be the \e only thing in the path: if you want a circle as part of
a complex polygon you must use fl_arc()
\param[in] x,y,r center and radius of circle
*/
inline void fl_circle(double x, double y, double r) {fl_graphics_driver->circle(x,y,r); };
/**
Ends list of points, and draws.
*/
inline void fl_end_points() {fl_graphics_driver->end_points(); };
/**
Ends list of lines, and draws.
*/
inline void fl_end_line() {fl_graphics_driver->end_line(); };
/**
Ends closed sequence of lines, and draws.
*/
inline void fl_end_loop() {fl_graphics_driver->end_loop(); };
/**
Ends convex filled polygon, and draws.
*/
inline void fl_end_polygon() {fl_graphics_driver->end_polygon(); };
/**
Starts drawing a complex filled polygon.
The polygon may be concave, may have holes in it, or may be several
disconnected pieces. Call fl_gap() to separate loops of the path.
To outline the polygon, use fl_begin_loop() and replace each fl_gap()
with fl_end_loop();fl_begin_loop() pairs.
\note
For portability, you should only draw polygons that appear the same
whether "even/odd" or "non-zero" winding rules are used to fill them.
Holes should be drawn in the opposite direction to the outside loop.
*/
inline void fl_begin_complex_polygon() {fl_graphics_driver->begin_complex_polygon(); };
/**
Call fl_gap() to separate loops of the path.
It is unnecessary but harmless to call fl_gap() before the first vertex,
after the last vertex, or several times in a row.
*/
inline void fl_gap() {fl_graphics_driver->gap(); };
/**
Ends complex filled polygon, and draws.
*/
inline void fl_end_complex_polygon() {fl_graphics_driver->end_complex_polygon(); };
// get and use transformed positions:
FL_EXPORT double fl_transform_x(double x, double y);
FL_EXPORT double fl_transform_y(double x, double y);
FL_EXPORT double fl_transform_dx(double x, double y);
FL_EXPORT double fl_transform_dy(double x, double y);
FL_EXPORT void fl_transformed_vertex(double x, double y);
/**
Adds coordinate pair to the vertex list without further transformations.
\param[in] xf,yf transformed coordinate
*/
inline void fl_transformed_vertex(double xf, double yf) {fl_graphics_driver->transformed_vertex(xf,yf); };
/** @} */
/** \addtogroup fl_attributes
@{ */
/* NOTE: doxygen comments here to avoid triplication in os-specific sources */
// Fonts:
/**
Sets the current font, which is then used in various drawing routines.
You may call this outside a draw context if necessary to call fl_width(),
@@ -179,9 +448,7 @@ FL_EXPORT void fl_transformed_vertex(double x, double y);
The size of the font is measured in pixels and not "points".
Lines should be spaced \p size pixels apart or more.
*/
// Fonts:
FL_EXPORT void fl_font(Fl_Font face, Fl_Fontsize size);
inline void fl_font(Fl_Font face, Fl_Fontsize size) { fl_graphics_driver->font(face,size); };
extern FL_EXPORT Fl_Font fl_font_; ///< current font index
/**
@@ -189,7 +456,7 @@ extern FL_EXPORT Fl_Font fl_font_; ///< current font index
This can be used to save/restore the font.
*/
inline Fl_Font fl_font() {return fl_font_;}
/** current font size */
/** \brief current font size */
extern FL_EXPORT Fl_Fontsize fl_size_;
/**
Returns the \p size set by the most recent call to fl_font().
@@ -216,7 +483,7 @@ FL_EXPORT double fl_width(const char* txt, int n);
/** Return the typographical width of a single character :
\note if a valid fl_gc is NOT found then it uses the first window gc,
or the screen gc if no fltk window is available when called. */
FL_EXPORT double fl_width(Fl_Char);
FL_EXPORT double fl_width(unsigned int);
/** Determine the minimum pixel dimensions of a nul-terminated string.
Usage: given a string "txt" drawn using fl_draw(txt, x, y) you would determine
@@ -280,23 +547,23 @@ FL_EXPORT void fl_draw(const char* str, int x, int y);
Draws a nul-terminated string starting at the given location and
rotating \p angle degrees counterclockwise.
This version of fl_draw provides direct access to the text drawing
function of the underlying OS and suported for Xft, Win32 and MacOS
fltk subset.
function of the underlying OS and is supported by Xft, Win32 and MacOS
fltk subsets.
*/
FL_EXPORT void fl_draw(int angle,const char* str, int x, int y);
FL_EXPORT void fl_draw(int angle, const char* str, int x, int y);
/**
Draws an array of \p n characters starting at the given location.
*/
FL_EXPORT void fl_draw(const char* str, int n, int x, int y);
inline void fl_draw(const char* str, int n, int x, int y) {fl_graphics_driver->draw(str,n,x,y); };
/**
Draws an array of \p n characters starting at the given location,
rotating \p angle degrees counterclockwise.
*/
FL_EXPORT void fl_draw(int angle,const char* str, int n, int x, int y);
inline void fl_draw(int angle,const char* str, int n, int x, int y) {fl_graphics_driver->draw(angle,str,n,x,y); };
/**
Draws an array of \p n characters right to left starting at given location.
*/
FL_EXPORT void fl_rtl_draw(const char*, int n, int x, int y);
inline void fl_rtl_draw(const char* str, int n, int x, int y) {fl_graphics_driver->rtl_draw(str,n,x,y); };
FL_EXPORT void fl_measure(const char* str, int& x, int& y,
int draw_symbols = 1);
FL_EXPORT void fl_draw(const char* str, int x, int y, int w, int h,
@@ -313,15 +580,6 @@ FL_EXPORT void fl_frame2(const char* s, int x, int y, int w, int h);
FL_EXPORT void fl_draw_box(Fl_Boxtype, int x, int y, int w, int h, Fl_Color);
// images:
/**
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);
/**
Draw an 8-bit per color RGB or luminance image.
@@ -356,13 +614,15 @@ typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf);
any visual of 8 bits or less, and all common TrueColor visuals up
to 32 bits.
*/
FL_EXPORT void fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0);
inline void fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0)
{ fl_graphics_driver->draw_image(buf, X, Y, W, H, D, L); };
/**
Draw a gray-scale (1 channel) image.
\see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L)
*/
FL_EXPORT void fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
inline void fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0)
{ fl_graphics_driver->draw_image_mono(buf, X, Y, W, H, D, L); };
/**
Draw image using callback function to generate image data.
@@ -396,7 +656,8 @@ FL_EXPORT void fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int
If \p D is 4 or more, you must fill in the unused bytes with zero.
*/
FL_EXPORT void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
inline void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3)
{ fl_graphics_driver->draw_image(cb, data, X, Y, W, H, D); };
/**
Draw gray-scale image using callback function to generate image data.
@@ -441,8 +702,9 @@ FL_EXPORT int fl_measure_pixmap(const char* const* cdata, int &w, int &h);
// other:
FL_EXPORT void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
void (*draw_area)(void*, int,int,int,int), void* data);
FL_EXPORT const char* fl_shortcut_label(Fl_Shortcut shortcut);
FL_EXPORT const char* fl_shortcut_label(Fl_Shortcut shortcut, const char **eom);
FL_EXPORT const char* fl_shortcut_label(unsigned int shortcut);
FL_EXPORT const char* fl_shortcut_label(unsigned int shortcut, const char **eom);
FL_EXPORT unsigned int fl_old_shortcut(const char* s);
FL_EXPORT void fl_overlay_rect(int x,int y,int w,int h);
FL_EXPORT void fl_overlay_clear();
FL_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg=FL_BLACK, Fl_Color bg=FL_WHITE);
@@ -468,5 +730,5 @@ FL_EXPORT int fl_add_symbol(const char* name, void (*drawit)(Fl_Color), int scal
#endif
//
// End of "$Id: fl_draw.H 6878 2009-09-17 22:12:24Z matt $".
// End of "$Id: fl_draw.H 7659 2010-07-01 13:21:32Z manolo $".
//

View File

@@ -1,5 +1,5 @@
/*
* "$Id: fl_types.h 6299 2008-09-18 19:09:34Z fabien $"
* "$Id: fl_types.h 6942 2009-11-18 12:22:51Z AlbrechtS $"
*
* Simple "C"-style types for the Fast Light Tool Kit (FLTK).
*
@@ -62,5 +62,5 @@ typedef unsigned int Fl_Char;
#endif
/*
* End of "$Id: fl_types.h 6299 2008-09-18 19:09:34Z fabien $".
* End of "$Id: fl_types.h 6942 2009-11-18 12:22:51Z AlbrechtS $".
*/

View File

@@ -1,4 +1,4 @@
/* "$Id: $"
/* "$Id: fl_utf8.h 7551 2010-04-20 21:43:31Z engelsman $"
*
* Author: Jean-Marc Lienher ( http://oksid.ch )
* Copyright 2000-2009 by O'ksi'D.
@@ -38,8 +38,8 @@
#ifndef _HAVE_FL_UTF8_HDR_
#define _HAVE_FL_UTF8_HDR_
#include "FL/Fl_Export.H"
#include "FL/fl_types.h"
#include "Fl_Export.H"
#include "fl_types.h"
#include <stdio.h>
#include <string.h>
@@ -142,6 +142,15 @@ FL_EXPORT int fl_utf8locale();
* type of the src text. */
FL_EXPORT int fl_utf8test(const char *src, unsigned len);
/* XX: return width of "raw" ucs character in columns.
* for internal use only */
FL_EXPORT int fl_wcwidth_(unsigned int ucs);
/* XX: return width of utf-8 character string in columns.
* NOTE: this may also do C1 control character (0x80 to 0x9f) to CP1252 mapping,
* depending on original build options */
FL_EXPORT int fl_wcwidth(const char *src);
/* OD: Return true if the character is non-spacing */
FL_EXPORT unsigned int fl_nonspacing(unsigned int ucs);
@@ -246,5 +255,5 @@ FL_EXPORT char fl_make_path( const char *path );
#endif /* _HAVE_FL_UTF8_HDR_ */
/*
* End of "$Id: $".
* End of "$Id: fl_utf8.h 7551 2010-04-20 21:43:31Z engelsman $".
*/

View File

@@ -1,5 +1,5 @@
//
// "$Id: mac.H 6614 2009-01-01 16:11:32Z matt $"
// "$Id: mac.H 7663 2010-07-01 16:51:28Z manolo $"
//
// Mac header file for the Fast Light Tool Kit (FLTK).
//
@@ -36,24 +36,66 @@
// Standard MacOS Carbon API includes...
#include <Carbon/Carbon.h>
#include <config.h>
#ifndef MAC_OS_X_VERSION_10_3
#define MAC_OS_X_VERSION_10_3 1030
#endif
#ifndef MAC_OS_X_VERSION_10_4
#define MAC_OS_X_VERSION_10_4 1040
#endif
#ifndef MAC_OS_X_VERSION_10_5
#define MAC_OS_X_VERSION_10_5 1050
#endif
#ifndef MAC_OS_X_VERSION_10_6
#define MAC_OS_X_VERSION_10_6 1060
#endif
#ifndef MAC_OS_X_VERSION_MAX_ALLOWED
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3
#endif
#ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h
#if defined(__LP64__) && __LP64__
typedef double CGFloat;
#else
typedef float CGFloat;
#endif
#endif // CGFLOAT_DEFINED
// Now make some fixes to the headers...
#undef check // Dunno where this comes from...
// Some random X equivalents
typedef WindowPtr Window;
struct XPoint { int x, y; };
struct XRectangle {int x, y, width, height;};
typedef RgnHandle Fl_Region;
void fl_clip_region(Fl_Region);
typedef void *Window; // this is really a pter to the subclass FLWindow of NSWindow
typedef struct flCocoaRegion {
int count;
CGRect *rects;
} *Fl_Region; // a region is the union of a series of rectangles
extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h);
inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
Fl_Region R = NewRgn();
SetRectRgn(R, x, y, x+w, y+h);
Fl_Region R = (Fl_Region)malloc(sizeof(*R));
R->count = 1;
R->rects = (CGRect *)malloc(sizeof(CGRect));
*(R->rects) = fl_cgrectmake_cocoa(x, y, w, h);
return R;
}
inline void XDestroyRegion(Fl_Region r) {
DisposeRgn(r);
if(r) {
free(r->rects);
free(r);
}
}
extern void *fl_default_cursor;
extern void *fl_system_menu;
typedef CGContextRef Fl_Offscreen;
typedef CGImageRef Fl_Bitmask;
void fl_clip_region(Fl_Region);
# include "Fl_Window.H"
@@ -62,15 +104,15 @@ inline void XDestroyRegion(Fl_Region r) {
class Fl_X
{
public:
Window xid; // Mac WindowPtr
GWorldPtr other_xid; // pointer for offscreen bitmaps (doublebuffer)
Window xid; // Cocoa: FLWindow* ; Carbon: WindowRef
Fl_Offscreen other_xid; // pointer for offscreen bitmaps (doublebuffer)
Fl_Window *w; // FLTK window for
Fl_Region region;
Fl_Region subRegion; // region for this specific subwindow
Fl_X *next; // linked tree to support subwindows
Fl_X *xidChildren, *xidNext; // more subwindow tree
int wait_for_expose;
CursHandle cursor;
void *cursor; // is really NSCursor*
static Fl_X* first;
static Fl_X* i(const Fl_Window* w) {return w->i;}
static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&);
@@ -78,8 +120,6 @@ public:
void flush();
// Quartz additions:
CGContextRef gc; // graphics context (NULL when using QD)
static ATSUTextLayout atsu_layout; // windows share a global font
static ATSUStyle atsu_style;
static void q_fill_context(); // fill a Quartz context with current FLTK state
static void q_clear_clipping(); // remove all clipping from a Quartz context
static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc
@@ -87,9 +127,13 @@ public:
static void q_end_image();
};
extern void MacDestroyWindow(Fl_Window*,WindowPtr);
extern void MacMapWindow(Fl_Window*,WindowPtr);
extern void MacUnmapWindow(Fl_Window*,WindowPtr);
extern void MacDestroyWindow(Fl_Window*,void *);
extern void MacMapWindow(Fl_Window*,void *);
extern void MacUnmapWindow(Fl_Window*,void *);
extern WindowRef MACwindowRef(Fl_Window *w);
extern Fl_Region MacRectRegionIntersect(Fl_Region current, int x,int y,int w, int h);
extern void MacCollapseWindow(Window w);
extern int MacUnlinkWindow(Fl_X*,Fl_X*start=0L);
inline Window fl_xid(const Fl_Window*w)
@@ -97,8 +141,6 @@ inline Window fl_xid(const Fl_Window*w)
return Fl_X::i(w)->xid;
}
extern CursHandle fl_default_cursor;
extern struct Fl_XMap {
RGBColor rgb;
ulong pen;
@@ -107,10 +149,8 @@ extern struct Fl_XMap {
extern FL_EXPORT void *fl_display;
extern FL_EXPORT Window fl_window;
extern FL_EXPORT CGContextRef fl_gc;
extern FL_EXPORT Handle fl_system_menu;
extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
typedef GWorldPtr Fl_Offscreen;
extern Fl_Offscreen fl_create_offscreen(int w, int h);
extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy);
@@ -118,7 +158,6 @@ extern void fl_delete_offscreen(Fl_Offscreen gWorld);
extern void fl_begin_offscreen(Fl_Offscreen gWorld);
extern void fl_end_offscreen();
typedef GWorldPtr Fl_Bitmask; // Carbon requires a 1-bit GWorld instead of a BitMap
extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
@@ -126,12 +165,30 @@ extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
extern void fl_open_display();
// Register a function for opening files via the finder...
extern void fl_open_callback(void (*cb)(const char *));
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
#endif // FL_DOXYGEN
/** \defgroup group_macosx Mac OS X-specific functions
@{ */
/** @brief Register a function called for each file dropped onto an application icon
* \note \#include <FL/x.H>
*/
extern void fl_open_callback(void (*cb)(const char *));
/**
* \brief Attaches a callback to the "About myprog" item of the system application menu.
* \note \#include <FL/x.H>
*
* \param cb a callback that will be called by "About myprog" menu item
* with NULL 1st argument.
* \param user_data a pointer transmitted as 2nd argument to the callback.
* \param shortcut optional shortcut to attach to the "About myprog" menu item (e.g., FL_META+'a')
*/
extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0);
/** @} */
//
// End of "$Id: mac.H 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: mac.H 7663 2010-07-01 16:51:28Z manolo $".
//

View File

@@ -1,13 +0,0 @@
data 'MBAR' (128) {
$"0001 0080" /* ...<EFBFBD> */
};
data 'MENU' (128, "Apple") {
$"0080 0000 0000 0000 0000 FFFF FFFB 0114" /* .<2E>........<EFBFBD><EFBFBD><EFBFBD><EFBFBD>.. */
$"0A41 626F 7574 2046 4C54 4B00 0000 0001" /* <20>About FLTK..... */
$"2D00 0000 0000" /* -..... */
};
data 'carb' (0) {
};

View File

@@ -1,5 +1,5 @@
//
// "$Id: math.h 6614 2009-01-01 16:11:32Z matt $"
// "$Id: math.h 7504 2010-04-14 20:17:44Z matt $"
//
// Math header file for the Fast Light Tool Kit (FLTK).
//
@@ -25,19 +25,18 @@
// http://www.fltk.org/str.php
//
// Xcode on OS X includes files by recursing down into directories.
// This code catches the cycle and directly includes the required file.
#ifdef fl_math_h_cyclic_include
# include "/usr/include/math.h"
#endif
#ifndef fl_math_h
# define fl_math_h
// Apple's ProjectBuilder has the nasty habit of including recursively
// down the file tree. To avoid re-including <FL/math.h> we must
// directly include the systems math file. (Plus, I could not find a
// predefined macro for ProjectBuilder builds, so we have to define it
// in the project)
# if defined(__APPLE__) && defined(__PROJECTBUILDER__)
# include "/usr/include/math.h"
# else
# include <math.h>
# endif
# define fl_math_h_cyclic_include
# include <math.h>
# undef fl_math_h_cyclic_include
# ifdef __EMX__
# include <float.h>
@@ -68,5 +67,5 @@ inline double copysign(double a, double b) {return b<0 ? -a : a;}
//
// End of "$Id: math.h 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: math.h 7504 2010-04-14 20:17:44Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: names.h 6731 2009-03-31 22:41:10Z greg.ercolano $"
// "$Id: names.h 7159 2010-02-26 18:10:54Z greg.ercolano $"
//
// Event names header file for the Fast Light Tool Kit (FLTK).
//
@@ -30,6 +30,25 @@
#ifndef FL_NAMES_H
#define FL_NAMES_H
/** \defgroup fl_events Events handling functions
@{
*/
/**
This is an array of event names you can use to convert event numbers into names.
The array gets defined inline wherever your '\#include <FL/names.h>' appears.
\b Example:
\code
#include <FL/names.h> // array will be defined here
int MyClass::handle(int e) {
printf("Event was %s (%d)\n", fl_eventnames[e], e);
// ..resulting output might be e.g. "Event was FL_PUSH (1)"..
[..]
}
\endcode
*/
const char * const fl_eventnames[] =
{
"FL_NO_EVENT",
@@ -58,6 +77,23 @@ const char * const fl_eventnames[] =
"FL_DND_RELEASE",
};
/**
This is an array of font names you can use to convert font numbers into names.
The array gets defined inline wherever your '\#include <FL/names.h>' appears.
\b Example:
\code
#include <FL/names.h> // array will be defined here
int MyClass::my_callback(Fl_Widget *w, void*) {
int fnum = w->labelfont();
// Resulting output might be e.g. "Label's font is FL_HELVETICA (0)"
printf("Label's font is %s (%d)\n", fl_fontnames[fnum], fnum);
// ..resulting output might be e.g. "Label's font is FL_HELVETICA (0)"..
[..]
}
\endcode
*/
const char * const fl_fontnames[] =
{
"FL_HELVETICA",
@@ -78,8 +114,10 @@ const char * const fl_fontnames[] =
"FL_ZAPF_DINGBATS",
};
/** @} */
#endif /* FL_NAMES_H */
//
// End of "$Id: names.h 6731 2009-03-31 22:41:10Z greg.ercolano $".
// End of "$Id: names.h 7159 2010-02-26 18:10:54Z greg.ercolano $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: win32.H 6614 2009-01-01 16:11:32Z matt $"
// "$Id: win32.H 7671 2010-07-09 17:31:33Z manolo $"
//
// WIN32 header file for the Fast Light Tool Kit (FLTK).
//
@@ -34,7 +34,6 @@
# error "Never use <FL/win32.H> directly; include <FL/x.H> instead."
#endif // !Fl_X_H
#include <winsock2.h>
#include <windows.h>
// In some of the distributions, the gcc header files are missing some stuff:
#ifndef LPMINMAXINFO
@@ -46,15 +45,15 @@
#define VK_APPS 0x5D
#endif
#include <FL/Fl_Device.H>
// some random X equivalents
typedef HWND Window;
typedef POINT XPoint;
struct XRectangle {int x, y, width, height;};
typedef HRGN Fl_Region;
FL_EXPORT void fl_clip_region(Fl_Region);
inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
return CreateRectRgn(x,y,x+w,y+h);
}
extern Fl_Region XRectangleRegion(int x, int y, int w, int h);
inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);}
inline void XClipBox(Fl_Region r,XRectangle* rect) {
RECT win_rect; GetRgnBox(r,&win_rect);
@@ -122,16 +121,19 @@ extern FL_EXPORT void fl_save_dc( HWND w, HDC dc);
// off-screen pixmaps: create, destroy, draw into, copy to window
typedef HBITMAP Fl_Offscreen;
#define fl_create_offscreen(w, h) CreateCompatibleBitmap(fl_gc, w, h)
#define fl_create_offscreen(w, h) \
CreateCompatibleBitmap( (fl_gc ? fl_gc : fl_GetDC(0) ) , w, h)
extern FL_EXPORT HDC fl_makeDC(HBITMAP);
# define fl_begin_offscreen(b) \
HDC _sgc=fl_gc; Window _sw=fl_window; \
Fl_Surface_Device *_ss = fl_surface; fl_display_device->set_current(); \
fl_gc=fl_makeDC(b); int _savedc = SaveDC(fl_gc); fl_window=(HWND)b; fl_push_no_clip()
# define fl_end_offscreen() \
fl_pop_clip(); RestoreDC(fl_gc, _savedc); DeleteDC(fl_gc); fl_window=_sw; fl_gc = _sgc
fl_pop_clip(); RestoreDC(fl_gc, _savedc); DeleteDC(fl_gc); _ss->set_current(); fl_window=_sw; fl_gc = _sgc
FL_EXPORT void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
FL_EXPORT void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
@@ -150,5 +152,5 @@ inline void fl_open_callback(void (*)(const char *)) {}
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
#endif // FL_DOXYGEN
//
// End of "$Id: win32.H 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: win32.H 7671 2010-07-09 17:31:33Z manolo $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: x.H 6614 2009-01-01 16:11:32Z matt $"
// "$Id: x.H 7671 2010-07-09 17:31:33Z manolo $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@@ -65,11 +65,35 @@ extern FL_EXPORT int fl_screen;
extern FL_EXPORT XVisualInfo *fl_visual;
extern FL_EXPORT Colormap fl_colormap;
// access to core fonts:
// This class provides a "smart pointer" that returns a pointer to an XFontStruct.
// The global variable fl_xfont can be called wherever a bitmap "core" font is
// needed, e.g. when rendering to a GL context under X11.
// With Xlib / X11 fonts, fl_xfont will return the current selected font.
// With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most
// similar to (usually the same as) the current XFT font.
class Fl_XFont_On_Demand
{
public:
Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { }
Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x)
{ ptr = x.ptr; return *this; }
Fl_XFont_On_Demand& operator=(XFontStruct* p)
{ ptr = p; return *this; }
XFontStruct* value();
operator XFontStruct*() { return value(); }
XFontStruct& operator*() { return *value(); }
XFontStruct* operator->() { return value(); }
bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; }
bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; }
private:
XFontStruct *ptr;
};
extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
// drawing functions:
extern FL_EXPORT GC fl_gc;
extern FL_EXPORT Window fl_window;
//extern FL_EXPORT XFontStruct* fl_xfont;
extern FL_EXPORT XUtf8FontStruct* fl_xfont;
extern FL_EXPORT void *fl_xftfont;
FL_EXPORT ulong fl_xpixel(Fl_Color i);
FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
@@ -86,16 +110,20 @@ extern FL_EXPORT ulong fl_event_time;
// off-screen pixmaps: create, destroy, draw into, copy to window:
typedef ulong Fl_Offscreen;
#define fl_create_offscreen(w,h) \
XCreatePixmap(fl_display, fl_window, w, h, fl_visual->depth)
# define fl_create_offscreen(w,h) \
XCreatePixmap(fl_display, \
(fl_surface->type() == Fl_Display_Device::device_type ? \
fl_window : fl_xid(Fl::first_window()) ) , \
w, h, fl_visual->depth)
// begin/end are macros that save the old state in local variables:
# define fl_begin_offscreen(pixmap) \
Window _sw=fl_window; fl_window=pixmap; fl_push_no_clip()
Window _sw=fl_window; fl_window=pixmap; \
Fl_Surface_Device *_ss = fl_surface; fl_display_device->set_current(); \
fl_push_no_clip()
# define fl_end_offscreen() \
fl_pop_clip(); fl_window = _sw
fl_pop_clip(); fl_window = _sw; _ss->set_current()
# define fl_copy_offscreen(x,y,w,h,pixmap,srcx,srcy) \
XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y)
extern void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
# define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap)
// Bitmap masks
@@ -145,5 +173,5 @@ extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b)
#endif
//
// End of "$Id: x.H 6614 2009-01-01 16:11:32Z matt $".
// End of "$Id: x.H 7671 2010-07-09 17:31:33Z manolo $".
//

View File

@@ -4,20 +4,20 @@
This file listst the differences between FLTK 1 and FLTK 2 with annotations
for a possible implementation of FLTK 3. The all new and improved FLTK 3
needs to be compatible with 1 and 2. It must have a moder API, plenty of
widgets, lots of options, customization at run-time, but still be easily
portable, fast, and of course light.
needs to be compatible with 1 and 2. It must have a modern API, a complete set
of widgets, lots of options, customization at run-time, but still be easily
portable, fast, and, of course, light.
FLTK 1 has become a nice starting point for the first steps in GUI
programming. It runs on al major platform (and on many minor ones
FLTK 1 has evolved to be a great starting point for the first steps in GUI
programming. It runs on all major platform (and on many minor ones
as well), is small, compact, and easy to use. FLTK 2 was the
attempt to continue the success of FLTK 1 with a much cleaber API
attempt to continue the success of FLTK 1 with a clearer and more modern API
and many important details improved. Unfortunately many users never
made the jump to FLTK 2 and so it not only ended in a crawling slow
branch, it also became instable and at last unmaintainable.
FLTK 3 sets out to surprise FLTK 1 users and satisfy FLTK 2 junkies.
It will basically be the improved FLTK 2 API combined with the quite
It will basically be the improved FLTK 2 API combined with the proven and
stable innards of FLTK 1. As an extra bonus, FLTK 3 will be compatible
to 1 and 2. Just prepend your code with the "coding_style" instruction
and FLTK 3 will do the rest. It is even possible to intermix F1 and
@@ -34,7 +34,7 @@ on the Forms Library, FLTK 2 is Bill's take on how FLTK 1 should have been.
This chapter outlines the biggest differences between version.
(1) Coordinate System: FLTK 1 child coordinates are always relative to the
window, not as most would expect to the parent. FLTK 2 does the logical
window, not as most would expect to the parent group. FLTK 2 does the logical
thing and uses group-relative origins. This is somewhat difficult to port
if we want to stay downward compatible. Fl_Widget will need an additional
flag indicating absolute or relative coordinates.
@@ -42,10 +42,11 @@ flag indicating absolute or relative coordinates.
(2) Pulldown Menus: The developers of the Forms Library did not implement
the idea of hierarchies all the way through. Pulldown menus, which are
hierarchical by nature, were instead implemented as a list with lots of
tricks and cludges to make them usable. FLTK 2 went half way by using the
tricks and kludges to make them usable. FLTK 2 went half way by using the
existing Windget/Group relation to create menus, however, menu items are
still specialized widgets. For FLTK 3, I would like to allow any widget
inside a pulldown menu.
inside a pulldown menu, using the hierarchical nature of the FLTK base class
Fl_Widget.
(3) Browsers and Tree Views: Browsers in FLTK1 are implemented even worse
than Pulldown Menus. FLTK 2 solved the issues in a similar way, and here
@@ -53,22 +54,24 @@ again, I prefer the FLTK 2 way very mch, but also would like to extend
functionality to allow arbitrary widgets as list items. A Tree-like
widget comes free with the FLTK 2 concept. FLTK 1 has no such thing and
even Fluid had to hack the library badly to generate a tree view.
FLTK 1.3 now comes with Greg's Fl_Tree widget.
(4) Namespaces: this is a minr issue that I include for completeness. FLTK 2
introduces the ftk namespace, renaming all widgets. FLTK 3 will use the
introduces the fltk namespace, renaming all widgets. FLTK 3 will use the
FLTK 2 naming scheme and map FLTK 1 class names using typedefs. This is, as
most things in programming are, a compromise. The "coding_style" function
must be used to switch between FLTK 1 and FLTK 2 code. No worries though,
it's easy and straight forward.
(5) Layout: FLTK 1 uses a top-down approach for widget layout in which the
parent widget decides about the childs size "resize(x, y, w, h)". In FLTK 2
any widget can call "layout()" which will query children for their preffered
parent widget decides about the child's size "resize(x, y, w, h)". In FLTK 2
any widget can call "layout()" which will query children for their preferred
size and propagate the information up. This is a great concept that FLTK 3
should adapt, plus it is compatible.
(6) Ractangle: FLTK 2's base class is fltk::Rectangle. This is nice and
easy to implement. The API is pretty much the same in both versions.
(6) Rectangle: FLTK uses discrete coordinates and sizes. FLTK 2's base class is
fltk::Rectangle. This is nice and easy to implement. The API is pretty much the
same in both versions.
(7) Styles: FLTK 2 uses a minimal number of styles to define the basic
(and often repeated) parameters of every widget. API's are similar though,
@@ -184,8 +187,9 @@ correspond, and how they could be implemented in FLTK 3.
2: class Dial
*: should map easily
1:
1: class Fl_Box
2: class Divider
*:
1: class Fl_Double_Window
2: class DoubleBufferWindow
@@ -194,7 +198,7 @@ correspond, and how they could be implemented in FLTK 3.
1: class Fl_End
2:
1:
1: Fl_Box
2: class EngravedLabel
1: class Fl_File_Browser
@@ -326,8 +330,9 @@ correspond, and how they could be implemented in FLTK 3.
1:
2: class InvisibleBox
1:
1: struct Fl_Menu_Item
2: class Item
*: this will be hard to emulate!
1:
2: class ItemGroup
@@ -365,7 +370,7 @@ correspond, and how they could be implemented in FLTK 3.
1: class Fl_Menu_Window
2: class MenuWindow
1:
1: class Fl_Screen?
2: class Monitor
1: class Fl_Multi_Browser
@@ -382,7 +387,7 @@ correspond, and how they could be implemented in FLTK 3.
2: class MultiLineOutput
*: should map easily
1:
1: Fl::lock()
2: class Mutex
1: class Fl_Nice_Slider
@@ -408,7 +413,7 @@ correspond, and how they could be implemented in FLTK 3.
1: class Fl_Pack
2: class PackedGroup
*: should map easily, FLTK 2 has soem additional functionaity
*: should map easily, FLTK 2 has some additional functionaity
1: class Fl_Pixmap
2:
@@ -683,4 +688,10 @@ correspond, and how they could be implemented in FLTK 3.
1:
2: struct NamedStyle
---
This is how to output all symbols in a library (interestingly, this seems
to output symbols for functions that are likely inlined as well)
> nm -g -j lib/libfltk.a | c++filt | sort -u | more

View File

@@ -1,6 +1,6 @@
README.win32 - Building FLTK under Windows
------------------------------------------
Last Update: May 2007 for release 1.1.8
Last Update: July 2010 for release 1.3.x
INTRODUCTION
@@ -10,24 +10,30 @@ INTRODUCTION
the GNU-like build configurations in the "makefiles"
subdirectory.
FLTK 1.3 and later is officially supported on Windows
(2000,) 2003, XP, and later. Older Windows versions are
not officially supported, but may still work. The main
reason is that the OS version needs to support UTF-8.
FLTK 1.3 is known to work on Windows 7 and Vista.
FLTK currently supports the following development
environments on the Windows platform:
- Microsoft Visual C++ 6.0, VC2005 and VC.NET using the
supplied workspace and project files. Be sure to get
your service packs!
- Free Microsoft Visual C++ 2008 Express and Visual
C++ 2010 Express using the supplied workspace and
project files. Older and the commercial versions can
be used as well, if they can open the project files.
Be sure to get your service packs!
- Borland C++ Builder 5 and 6 using the supplied IDE
files. These files are not as actively maintained as
the VC and GNU versions, so may not work for you.
The project files can be found in the ide/ directory.
Please read ide/README.IDE for more info about this.
- Watcom. There is a partial solution for the Watcom
toolchain. It is no longer actively maintained.
- GNU toolsets (Cygwin or MinGW) hosted on Windows.
- GNU toolsets (Cygwin or MinGW) hosted on Windows
9x/2000/NT/XP.
- Watcom. There is a partial solution for the Watcom
toolchain. It is no longer actively maintained.
This remainder of this document gives a brief overview of
The remainder of this document gives a brief overview of
compiling and using FLTK with the Cygwin and MinGW compiler
toolkits. Both toolkits provide a build environment based
around the GNU C/C++ compiler. Further information is
@@ -50,13 +56,18 @@ INTRODUCTION
the Cygwin DLL (compiled and linked with the "-mno-cygwin"
option) may be released under any license freely.
Note: Since December 2009, there is a new gcc 4.x compiler
that doesn't support the -mno-cygwin option anymore. You
must use the older gcc-3 compiler instead.
The MinGW distribution (Minimalist GNU for Windows) provides
a similar toolset but geared solely towards native Windows
development without the Unix-like POSIX library. The lack of
any libraries under the GPL or any other restrictive license
means that programs built with the MinGW environment may
always be released under any license freely. MinGW also
supplies a Unix-like build environment for Windows,
supplies a Unix-like build environment for Windows,
including MSYS (a Bourne-compatible shell) and the standard
Unix file utilities (ls, cat, grep, etc.)
@@ -178,7 +189,7 @@ WHY DOES A CONSOLE WINDOW APPEAR WHEN I RUN MY PROGRAM
(Note: A special case of this exists if running a MinGW
application from the command line of an MSYS shell, when an
application is able to write to stdout, even if compiled with
"-mwindows".)
"-mwindows". The same applies to Cygwin.)
HOW DO I GET OPENGL TO WORK?
@@ -194,13 +205,3 @@ HOW DO I GET OPENGL TO WORK?
will change this to compile and link in OpenGL.

View File

@@ -1,5 +1,5 @@
/*
* "$Id: configh.cmake.in 6614 2009-01-01 16:11:32Z matt $"
* "$Id: configh.cmake.in 7563 2010-04-28 03:15:47Z greg.ercolano $"
*
* Configuration file for the Fast Light Tool Kit (FLTK).
* @configure_input@
@@ -21,15 +21,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "fltk-bugs@fltk.org".
* Please report all bugs and problems on the following page:
*
* http://www.fltk.org/str.php
*/
/*
* Where to find files...
*/
#define FLTK_DATADIR "@FLTK_DATADIR@"
#define FLTK_DOCDIR "@FLTK_DOCDIR@"
#define FLTK_DATADIR "@PREFIX_DATA@"
#define FLTK_DOCDIR "@PREFIX_DOC@"
/*
* BORDER_WIDTH:
@@ -47,8 +49,6 @@
#define BORDER_WIDTH 2
#cmakedefine USE_X11 1
/*
* HAVE_GL:
*
@@ -56,7 +56,7 @@
* OpenGL, and FLTK will be smaller.
*/
#define HAVE_GL @HAVE_GL@
#cmakedefine01 HAVE_GL
/*
* HAVE_GL_GLU_H:
@@ -65,7 +65,15 @@
* (many broken Mesa RPMs do not...)
*/
#cmakedefine HAVE_GL_GLU_H @HAVE_GL_GLU_H@
#cmakedefine01 HAVE_GL_GLU_H
/*
* HAVE_GLXGETPROCADDRESSARB:
*
* Do you have the OpenGL glXGetProcAddressARB() function?
*/
#cmakedefine HAVE_GLXGETPROCADDRESSARB
/*
* USE_COLORMAP:
@@ -76,25 +84,29 @@
#define USE_COLORMAP 1
/*
* HAVE_XINERAMA
*
* Do we have the Xinerama library to support multi-head displays?
*/
#cmakedefine01 HAVE_XINERAMA
/*
* USE_XFT
*
* Use the new Xft library to draw anti-aliased text.
*/
#cmakedefine FOUND_XFT
#ifdef FOUND_XFT
#define USE_XFT 1
#else
#define USE_XFT 0
#endif
#cmakedefine01 USE_XFT
/*
* HAVE_XDBE:
*
* Do we have the X double-buffer extension?
*/
#define HAVE_XDBE 0
#cmakedefine01 HAVE_XDBE
/*
* USE_XDBE:
@@ -114,19 +126,20 @@
* other operating systems.
*/
#cmakedefine FLTK_APPLE
#ifdef FLTK_APPLE
#cmakedefine FLTK_QUARTZ
#ifdef FLTK_QUARTZ
#define USE_QUARTZ 1
#define __APPLE_QUARTZ__
#undef __APPLE_QD__
#else
#define USE_QUARTZ 0
#undef __APPLE_QUARTZ__
#define __APPLE_QD__
#endif
#endif
#cmakedefine USE_QUARTZ
#cmakedefine __APPLE_QUARTZ__ @__APPLE_QUARTZ__@
#cmakedefine __APPLE_COCOA__ @__APPLE_COCOA__@
#cmakedefine __APPLE_QD__ @__APPLE_QD__@
/*
* USE_X11
*
* Should we use X11 for the current platform
*
*/
#cmakedefine USE_X11 @USE_X11@
/*
* HAVE_OVERLAY:
@@ -154,7 +167,7 @@
* Byte order of your machine: 1 = big-endian, 0 = little-endian.
*/
#define WORDS_BIGENDIAN 0
#define WORDS_BIGENDIAN @WORDS_BIGENDIAN@
/*
* U16, U32, U64:
@@ -168,7 +181,8 @@
#cmakedefine U64 @U64@
/*
* HAVE_DIRENT_H, HAVE_SYS_NDIR_H, HAVE_SYS_DIR_H, HAVE_NDIR_H, HAVE_SCANDIR:
* HAVE_DIRENT_H, HAVE_SYS_NDIR_H, HAVE_SYS_DIR_H, HAVE_NDIR_H,
* HAVE_SCANDIR, HAVE_SCANDIR_POSIX:
*
* Where is <dirent.h> (used only by fl_file_chooser and scandir).
*/
@@ -178,6 +192,7 @@
#cmakedefine HAVE_SYS_DIR_H @HAVE_SYS_DIR_H@
#cmakedefine HAVE_NDIR_H @HAVE_NDIR_H@
#cmakedefine HAVE_SCANDIR @HAVE_SCANDIR@
#cmakedefine HAVE_SCANDIR_POSIX @HAVE_SCANDIR_POSIX@
/*
* Possibly missing sprintf-style functions:
@@ -196,7 +211,7 @@
#cmakedefine HAVE_STRLCPY @HAVE_STRLCPY@
/*
* 'locale' functions
* Do we have POSIX locale support?
*/
#cmakedefine HAVE_LOCALE_H @HAVE_LOCALE_H@
@@ -208,7 +223,7 @@
* Whether or not select() call has its own header file.
*/
#cmakedefine HAVE_SYS_SELECT_H @HAVE_SYS_SELECT_H@
#cmakedefine01 HAVE_SYS_SELECT_H
/*
* HAVE_SYS_STDTYPES_H:
@@ -224,7 +239,7 @@
* Use the poll() call provided on Linux and Irix instead of select()
*/
#define USE_POLL 0
#cmakedefine01 USE_POLL
/*
* Do we have various image libraries?
@@ -234,6 +249,23 @@
#cmakedefine HAVE_LIBZ @HAVE_LIBZ@
#cmakedefine HAVE_LIBJPEG @HAVE_LIBJPEG@
/*
* USE_CAIRO
*
* Do we have the cairo library available and want extended cairo use in fltk ?
* will implies to link cairo.lib in all fltk based apps.
*/
#cmakedefine USE_CAIRO @USE_CAIRO@
/*
* HAVE_CAIRO
*
* Do we have the cairo library available?
*/
#cmakedefine HAVE_CAIRO @HAVE_CAIRO@
/*
* Which header file do we include for libpng?
*/
@@ -252,20 +284,45 @@
* Do we have POSIX threading?
*/
#cmakedefine CMAKE_USE_PTHREADS
#ifdef CMAKE_USE_PTHREADS
#define HAVE_PTHREAD 1
#else
#define HAVE_PTHREAD 0
#endif
#cmakedefine CMAKE_HAVE_PTHREAD_H
#ifdef CMAKE_HAVE_PTHREAD_H
#define HAVE_PTHREAD_H 1
#else
#define HAVE_PTHREAD_H 0
#endif
#cmakedefine HAVE_PTHREAD @HAVE_PTHREAD@
#cmakedefine01 HAVE_PTHREAD_H
/*
* End of "$Id: configh.cmake.in 6614 2009-01-01 16:11:32Z matt $".
* Do we have the ALSA library?
*/
#cmakedefine HAVE_ALSA_ASOUNDLIB_H @HAVE_ALSA_ASOUNDLIB_H@
/*
* Do we have the long long type?
*/
#cmakedefine HAVE_LONG_LONG @HAVE_LONG_LONG@
#ifdef HAVE_LONG_LONG
# define FLTK_LLFMT "%lld"
# define FLTK_LLCAST (long long)
#else
# define FLTK_LLFMT "%ld"
# define FLTK_LLCAST (long)
#endif /* HAVE_LONG_LONG */
/*
* Do we have the strtoll() function?
*/
#cmakedefine HAVE_STRTOLL @HAVE_STRTOLL@
#ifndef HAVE_STRTOLL
# define strtoll(nptr,endptr,base) strtol((nptr), (endptr), (base))
#endif /* !HAVE_STRTOLL */
/*
* Do we have the dlsym() function and header?
*/
#cmakedefine HAVE_DLFCN_H @HAVE_DLFCN_H@
#cmakedefine HAVE_DLSYM @HAVE_DLSYM@
/*
* End of "$Id: configh.cmake.in 7563 2010-04-28 03:15:47Z greg.ercolano $".
*/

View File

@@ -0,0 +1,388 @@
#!/bin/sh
#
# "$Id: fltk-config.in 6614 2009-01-01 16:11:32Z matt $"
#
# FLTK configuration utility.
#
# Copyright 2000-2009 by Bill Spitzak and others.
# Original version Copyright 2000 by James Dean Palmer
# Adapted by Vincent Penne and Michael Sweet
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
#
# Please report all bugs and problems on the following page:
#
# http://www.fltk.org/str.php
#
MAJOR_VERSION=1
MINOR_VERSION=3
PATCH_VERSION=0
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION"
APIVERSION="$MAJOR_VERSION.$MINOR_VERSION"
### BEGIN fltk-config
selfdir=`dirname "$0"`
prefix=/usr
exec_prefix=${prefix}
exec_prefix_set=no
bindir=${exec_prefix}/bin
includedir=${prefix}/include
libdir=${exec_prefix}/lib
srcdir=.
# compiler names
CC="gcc"
CXX="g++"
# flags for C++ compiler:
ARCHFLAGS=""
CFLAGS=" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT"
CXXFLAGS="-I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT"
LDFLAGS=" "
LDLIBS="-lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 "
OPTIM=" -Os -Wall -Wunused -Wno-format-y2k -fno-exceptions -fno-strict-aliasing"
CAIROFLAGS=""
# Check for local invocation, and update paths accordingly...
if test -f "$selfdir/FL/Fl_Window.H"; then
bindir="$selfdir/fluid"
includedir="$selfdir"
libdir="$selfdir/lib"
if test -f "$libdir/libfltk_jpeg.a"; then
CFLAGS="-I$includedir/jpeg $CFLAGS"
CXXFLAGS="-I$includedir/jpeg $CXXFLAGS"
fi
if test -f "$libdir/libfltk_z.a"; then
CFLAGS="-I$includedir/zlib $CFLAGS"
CXXFLAGS="-I$includedir/zlib $CXXFLAGS"
fi
if test -f "$libdir/libfltk_png.a"; then
CFLAGS="-I$includedir/png $CFLAGS"
CXXFLAGS="-I$includedir/png $CXXFLAGS"
fi
fi
if test -d $includedir/FL/images; then
CFLAGS="-I$includedir/FL/images $CFLAGS"
CXXFLAGS="-I$includedir/FL/images $CXXFLAGS"
fi
if test -f "$libdir/libfltk_cairo.a"; then
CFLAGS="$CAIROFLAGS $CFLAGS"
CXXFLAGS="$CAIROFLAGS $CXXFLAGS"
fi
# libraries to link with:
LIBNAME="../lib/libfltk.a"
DSONAME=""
DSOLINK=""
IMAGELIBS="-lpng -lz -ljpeg "
STATICIMAGELIBS="-lpng -lz -ljpeg "
CAIROLIBS=""
SHAREDSUFFIX=""
usage ()
{
echo "Usage: fltk-config [OPTIONS]
Options:
[--version]
[--api-version]
Options telling what we are doing:
[--use-gl] use GL
[--use-images] use extra image formats (PNG, JPEG)
[--use-glut] use glut compatibility layer
[--use-forms] use forms compatibility layer
[--use-cairo] use cairo graphics lib
Options telling what information we request:
[--cc] return C compiler used to compile FLTK
[--cxx] return C++ compiler used to compile FLTK
[--optim] return compiler optimization used to compile FLTK
[--cflags] return flags to compile C using FLTK
[--cxxflags] return flags to compile C++ using FLTK
[--ldflags] return flags to link against FLTK
[--ldstaticflags] return flags to link against static FLTK library
even if there are DSOs installed
[--libs] return FLTK libraries full path for dependencies
Options to compile and link an application:
[-g] compile the program with debugging information
[-Dname[=value]] compile the program with the given define
[--compile program.cxx]
[--post program] prepare the program for desktop use
"
exit $1
}
if test $# -eq 0; then
usage 1
fi
no_plugins=no
compile=
post=
debug=
# Parse command line options
while test $# -gt 0
do
case "$1" in
-*=*)
optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
;;
*)
optarg=
;;
esac
case $1 in
--version)
echo $VERSION
;;
--api-version)
echo $APIVERSION
;;
--cc)
echo $CC
;;
--cxx)
echo $CXX
;;
--optim)
echo_optim=yes
;;
--use-gl | --use-glut)
use_gl=yes
;;
--use-forms)
use_forms=yes
;;
--use-images)
use_images=yes
;;
--use-cairo)
use_cairo=yes
;;
--cflags)
echo_cflags=yes
;;
--cxxflags)
echo_cxxflags=yes
;;
--ldflags)
echo_ldflags=yes
;;
--ldstaticflags)
echo_ldstaticflags=yes
;;
--libs)
echo_libs=yes
;;
-g)
debug=-g
;;
-D*)
CXXFLAGS="$CXXFLAGS $1"
;;
--compile)
compile="$2"
shift
;;
--post)
post="$2"
shift
;;
*)
echo_help=yes
;;
esac
shift
done
if test "$includedir" != /usr/include; then
includes=-I$includedir
else
includes=
fi
if test "$libdir" != /usr/lib -a "$libdir" != /usr/lib32; then
libs=-L$libdir
else
libs=
fi
# Calculate needed libraries
LDSTATIC="$libdir/libfltk.a $LDLIBS"
LDLIBS="-lfltk$SHAREDSUFFIX $LDLIBS"
if test x$use_forms = xyes; then
LDLIBS="-lfltk_forms$SHAREDSUFFIX $LDLIBS"
LDSTATIC="$libdir/libfltk_forms.a $LDSTATIC"
fi
if test x$use_gl = xyes; then
LDLIBS="-lfltk_gl$SHAREDSUFFIX -lGLU -lGL $LDLIBS"
LDSTATIC="$libdir/libfltk_gl.a -lGLU -lGL $LDSTATIC"
fi
if test x$use_images = xyes; then
LDLIBS="-lfltk_images$SHAREDSUFFIX $IMAGELIBS $LDLIBS"
LDSTATIC="$libdir/libfltk_images.a $STATICIMAGELIBS $LDSTATIC"
fi
if test x$use_cairo = xyes; then
LDLIBS="-lfltk_cairo$SHAREDSUFFIX $CAIROLIBS $LDLIBS"
LDSTATIC="$libdir/libfltk_cairo.a $CAIROLIBS $LDSTATIC"
fi
LDLIBS="$DSOLINK $LDFLAGS $libs $LDLIBS"
LDSTATIC="$LDFLAGS $LDSTATIC"
# Answer to user requests
if test -n "$echo_help"; then
usage 1
fi
if test -n "$compile"; then
case "$compile" in
*.cxx)
prog="`basename \"$compile\" .cxx`"
;;
*.cpp)
prog="`basename \"$compile\" .cpp`"
;;
*.cc)
prog="`basename \"$compile\" .cc`"
;;
*.C)
prog="`basename \"$compile\" .C`"
;;
*)
echo "ERROR: Unknown/bad C++ source file extension on \"$compile\"!"
exit 1
;;
esac
post="$prog"
echo $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o "'$prog'" "'$compile'" $LDSTATIC
$CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o "$prog" "$compile" $LDSTATIC || exit 1
fi
if test -n "$post"; then
case "`uname`" in
Darwin)
echo Creating "'$post.app'" bundle for desktop...
id=`echo $post | tr ' ' '_'`
# Make the bundle directory and move the executable there
rm -rf "$post.app/Contents/MacOS"
mkdir -p "$post.app/Contents/MacOS"
mv "$post" "$post.app/Contents/MacOS"
# Make a shell script that runs the bundled executable
echo "#!/bin/sh" >"$post"
echo 'dir="`dirname '"'"'$0'"'"'`"' >>"$post"
echo 'exec "$dir/'"$post.app/Contents/MacOS/$post"'" "$@"' >>"$post"
chmod +x "$post"
# Make the simplest Info.plist needed for an application
cat >"$post.app/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<plist version="0.9">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>$post</string>
<key>CFBundleIdentifier</key>
<string>org.fltk.$id</string>
<key>CFBundleName</key>
<string>$post</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
</dict>
</plist>
EOF
;;
esac
fi
if test "$echo_cflags" = "yes"; then
echo $includes $CFLAGS
fi
if test "$echo_cxxflags" = "yes"; then
echo $includes $CXXFLAGS
fi
if test "$echo_optim" = "yes"; then
echo $OPTIM
fi
if test "$echo_ldflags" = "yes"; then
my_libs=
libdirs=$libs
for i in $LDLIBS ; do
if test $i != -L$libdir ; then
if test -z "$my_libs" ; then
my_libs="$i"
else
my_libs="$my_libs $i"
fi
fi
done
echo $libdirs $my_libs
fi
if test "$echo_ldstaticflags" = "yes"; then
echo $LDSTATIC
fi
if test "$echo_libs" = "yes"; then
echo $libdir/libfltk.a
if test x$use_forms = xyes; then
echo $libdir/libfltk_forms.a
fi
if test x$use_gl = xyes; then
echo $libdir/libfltk_gl.a
fi
if test x$use_cairo = xyes; then
echo $libdir/libfltk_cairo.a
fi
if test x$use_images = xyes; then
echo $libdir/libfltk_images.a
for lib in fltk_jpeg fltk_png fltk_z; do
if test -f $libdir/lib$lib.a; then
echo $libdir/lib$lib.a
fi
done
fi
fi
#
# End of "$Id: fltk-config.in 6614 2009-01-01 16:11:32Z matt $".
#

View File

@@ -0,0 +1,388 @@
#!/bin/sh
#
# "$Id: fltk-config.in 6614 2009-01-01 16:11:32Z matt $"
#
# FLTK configuration utility.
#
# Copyright 2000-2009 by Bill Spitzak and others.
# Original version Copyright 2000 by James Dean Palmer
# Adapted by Vincent Penne and Michael Sweet
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
#
# Please report all bugs and problems on the following page:
#
# http://www.fltk.org/str.php
#
MAJOR_VERSION=@FLTK_VERSION_MAJOR@
MINOR_VERSION=@FLTK_VERSION_MINOR@
PATCH_VERSION=@FLTK_VERSION_PATCH@
VERSION=@FLTK_VERSION_FULL@
APIVERSION=@FLTK_VERSION@
### BEGIN fltk-config
selfdir=`dirname "$0"`
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
exec_prefix_set=no
bindir=@PREFIX_BIN@
includedir=@CPREFIX_INCLUDE@
libdir=@PREFIX_LIB@
srcdir=.
# compiler names
CC="@CC@"
CXX="@CXX@"
# flags for C++ compiler:
ARCHFLAGS="@OPTION_ARCHFLAGS@"
CFLAGS="@C_FLAGS@"
CXXFLAGS="@CAIROFLAGS@@C_FLAGS@"
LDFLAGS="@LDFLAGS@"
LDLIBS="@LD_LIBS@"
OPTIM="@OPTION_OPTIM@"
CAIROFLAGS="@CAIROFLAGS@"
# Check for local invocation, and update paths accordingly...
if test -f "$selfdir/FL/Fl_Window.H"; then
bindir="$selfdir/fluid"
includedir="$selfdir"
libdir="$selfdir/lib"
if test -f "$libdir/libfltk_jpeg.a"; then
CFLAGS="-I$includedir/jpeg $CFLAGS"
CXXFLAGS="-I$includedir/jpeg $CXXFLAGS"
fi
if test -f "$libdir/libfltk_z.a"; then
CFLAGS="-I$includedir/zlib $CFLAGS"
CXXFLAGS="-I$includedir/zlib $CXXFLAGS"
fi
if test -f "$libdir/libfltk_png.a"; then
CFLAGS="-I$includedir/png $CFLAGS"
CXXFLAGS="-I$includedir/png $CXXFLAGS"
fi
fi
if test -d $includedir/FL/images; then
CFLAGS="-I$includedir/FL/images $CFLAGS"
CXXFLAGS="-I$includedir/FL/images $CXXFLAGS"
fi
if test -f "$libdir/libfltk_cairo.a"; then
CFLAGS="$CAIROFLAGS $CFLAGS"
CXXFLAGS="$CAIROFLAGS $CXXFLAGS"
fi
# libraries to link with:
LIBNAME="@LIBNAME@"
DSONAME="@DSONAME@"
DSOLINK="@DSOLINK@"
IMAGELIBS="@IMAGELIBS@"
STATICIMAGELIBS="@STATICIMAGELIBS@"
CAIROLIBS="@CAIROLIBS@"
SHAREDSUFFIX="@SHAREDSUFFIX@"
usage ()
{
echo "Usage: fltk-config [OPTIONS]
Options:
[--version]
[--api-version]
Options telling what we are doing:
[--use-gl] use GL
[--use-images] use extra image formats (PNG, JPEG)
[--use-glut] use glut compatibility layer
[--use-forms] use forms compatibility layer
[--use-cairo] use cairo graphics lib
Options telling what information we request:
[--cc] return C compiler used to compile FLTK
[--cxx] return C++ compiler used to compile FLTK
[--optim] return compiler optimization used to compile FLTK
[--cflags] return flags to compile C using FLTK
[--cxxflags] return flags to compile C++ using FLTK
[--ldflags] return flags to link against FLTK
[--ldstaticflags] return flags to link against static FLTK library
even if there are DSOs installed
[--libs] return FLTK libraries full path for dependencies
Options to compile and link an application:
[-g] compile the program with debugging information
[-Dname[=value]] compile the program with the given define
[--compile program.cxx]
[--post program] prepare the program for desktop use
"
exit $1
}
if test $# -eq 0; then
usage 1
fi
no_plugins=no
compile=
post=
debug=
# Parse command line options
while test $# -gt 0
do
case "$1" in
-*=*)
optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
;;
*)
optarg=
;;
esac
case $1 in
--version)
echo $VERSION
;;
--api-version)
echo $APIVERSION
;;
--cc)
echo $CC
;;
--cxx)
echo $CXX
;;
--optim)
echo_optim=yes
;;
--use-gl | --use-glut)
use_gl=yes
;;
--use-forms)
use_forms=yes
;;
--use-images)
use_images=yes
;;
--use-cairo)
use_cairo=yes
;;
--cflags)
echo_cflags=yes
;;
--cxxflags)
echo_cxxflags=yes
;;
--ldflags)
echo_ldflags=yes
;;
--ldstaticflags)
echo_ldstaticflags=yes
;;
--libs)
echo_libs=yes
;;
-g)
debug=-g
;;
-D*)
CXXFLAGS="$CXXFLAGS $1"
;;
--compile)
compile="$2"
shift
;;
--post)
post="$2"
shift
;;
*)
echo_help=yes
;;
esac
shift
done
if test "$includedir" != /usr/include; then
includes=-I$includedir
else
includes=
fi
if test "$libdir" != /usr/lib -a "$libdir" != /usr/lib32; then
libs=-L$libdir
else
libs=
fi
# Calculate needed libraries
LDSTATIC="$libdir/libfltk.a $LDLIBS"
LDLIBS="-lfltk$SHAREDSUFFIX $LDLIBS"
if test x$use_forms = xyes; then
LDLIBS="-lfltk_forms$SHAREDSUFFIX $LDLIBS"
LDSTATIC="$libdir/libfltk_forms.a $LDSTATIC"
fi
if test x$use_gl = xyes; then
LDLIBS="-lfltk_gl$SHAREDSUFFIX @GLLIB@ $LDLIBS"
LDSTATIC="$libdir/libfltk_gl.a @GLLIB@ $LDSTATIC"
fi
if test x$use_images = xyes; then
LDLIBS="-lfltk_images$SHAREDSUFFIX $IMAGELIBS $LDLIBS"
LDSTATIC="$libdir/libfltk_images.a $STATICIMAGELIBS $LDSTATIC"
fi
if test x$use_cairo = xyes; then
LDLIBS="-lfltk_cairo$SHAREDSUFFIX $CAIROLIBS $LDLIBS"
LDSTATIC="$libdir/libfltk_cairo.a $CAIROLIBS $LDSTATIC"
fi
LDLIBS="$DSOLINK $LDFLAGS $libs $LDLIBS"
LDSTATIC="$LDFLAGS $LDSTATIC"
# Answer to user requests
if test -n "$echo_help"; then
usage 1
fi
if test -n "$compile"; then
case "$compile" in
*.cxx)
prog="`basename \"$compile\" .cxx`"
;;
*.cpp)
prog="`basename \"$compile\" .cpp`"
;;
*.cc)
prog="`basename \"$compile\" .cc`"
;;
*.C)
prog="`basename \"$compile\" .C`"
;;
*)
echo "ERROR: Unknown/bad C++ source file extension on \"$compile\"!"
exit 1
;;
esac
post="$prog"
echo $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o "'$prog'" "'$compile'" $LDSTATIC
$CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o "$prog" "$compile" $LDSTATIC || exit 1
fi
if test -n "$post"; then
case "`uname`" in
Darwin)
echo Creating "'$post.app'" bundle for desktop...
id=`echo $post | tr ' ' '_'`
# Make the bundle directory and move the executable there
rm -rf "$post.app/Contents/MacOS"
mkdir -p "$post.app/Contents/MacOS"
mv "$post" "$post.app/Contents/MacOS"
# Make a shell script that runs the bundled executable
echo "#!/bin/sh" >"$post"
echo 'dir="`dirname '"'"'$0'"'"'`"' >>"$post"
echo 'exec "$dir/'"$post.app/Contents/MacOS/$post"'" "$@"' >>"$post"
chmod +x "$post"
# Make the simplest Info.plist needed for an application
cat >"$post.app/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<plist version="0.9">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>$post</string>
<key>CFBundleIdentifier</key>
<string>org.fltk.$id</string>
<key>CFBundleName</key>
<string>$post</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
</dict>
</plist>
EOF
;;
esac
fi
if test "$echo_cflags" = "yes"; then
echo $includes $CFLAGS
fi
if test "$echo_cxxflags" = "yes"; then
echo $includes $CXXFLAGS
fi
if test "$echo_optim" = "yes"; then
echo $OPTIM
fi
if test "$echo_ldflags" = "yes"; then
my_libs=
libdirs=$libs
for i in $LDLIBS ; do
if test $i != -L$libdir ; then
if test -z "$my_libs" ; then
my_libs="$i"
else
my_libs="$my_libs $i"
fi
fi
done
echo $libdirs $my_libs
fi
if test "$echo_ldstaticflags" = "yes"; then
echo $LDSTATIC
fi
if test "$echo_libs" = "yes"; then
echo $libdir/libfltk.a
if test x$use_forms = xyes; then
echo $libdir/libfltk_forms.a
fi
if test x$use_gl = xyes; then
echo $libdir/libfltk_gl.a
fi
if test x$use_cairo = xyes; then
echo $libdir/libfltk_cairo.a
fi
if test x$use_images = xyes; then
echo $libdir/libfltk_images.a
for lib in fltk_jpeg fltk_png fltk_z; do
if test -f $libdir/lib$lib.a; then
echo $libdir/lib$lib.a
fi
done
fi
fi
#
# End of "$Id: fltk-config.in 6614 2009-01-01 16:11:32Z matt $".
#

View File

@@ -232,19 +232,19 @@ fi
# Calculate needed libraries
LDSTATIC="$libdir/libfltk.a $LDLIBS"
LDLIBS="-lfltk$SHAREDSUFFIX"
LDLIBS="-lfltk$SHAREDSUFFIX $LDLIBS"
if test x$use_forms = xyes; then
LDLIBS="-lfltk_forms$SHAREDSUFFIX $LDLIBS"
LDSTATIC="$libdir/libfltk_forms.a $LDSTATIC"
fi
if test x$use_gl = xyes; then
LDLIBS="-lfltk_gl$SHAREDSUFFIX $LDLIBS"
LDLIBS="-lfltk_gl$SHAREDSUFFIX @GLLIB@ $LDLIBS"
LDSTATIC="$libdir/libfltk_gl.a @GLLIB@ $LDSTATIC"
fi
if test x$use_images = xyes; then
LDLIBS="-lfltk_images$SHAREDSUFFIX $LDLIBS"
LDSTATIC="$libdir/libfltk_images.a $IMAGELIBS $LDSTATIC"
LDLIBS="-lfltk_images$SHAREDSUFFIX $IMAGELIBS $LDLIBS"
LDSTATIC="$libdir/libfltk_images.a $STATICIMAGELIBS $LDSTATIC"
fi
if test x$use_cairo = xyes; then

View File

@@ -0,0 +1,126 @@
diff -upr /home/toby/development/svn/fltk/branch-1.3-r6970/src//CMakeLists.txt src//CMakeLists.txt
--- /home/toby/development/svn/fltk/branch-1.3-r6970/src//CMakeLists.txt 2010-07-26 12:08:34.947829872 +0200
+++ src//CMakeLists.txt 2010-07-26 12:10:34.290829872 +0200
@@ -1,3 +1,7 @@
+IF(COMMAND cmake_policy)
+ cmake_policy(SET CMP0003 NEW)
+ENDIF(COMMAND cmake_policy)
+
SET(CPPFILES
Fl.cxx
Fl_Adjuster.cxx
@@ -190,30 +194,30 @@ IF(X11_FOUND)
TARGET_LINK_LIBRARIES(fltk ${X11_LIBRARIES})
ENDIF(X11_FOUND)
-IF(OPENGL_FOUND)
- ADD_LIBRARY(fltk_gl ${GLCPPFILES})
- INSTALL_TARGETS(/lib fltk_gl)
- TARGET_LINK_LIBRARIES(fltk_gl fltk ${OPENGL_LIBRARIES})
- SET_TARGET_PROPERTIES(fltk_gl
- PROPERTIES
- VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
- SOVERSION ${FLTK_VERSION_PATCH})
-ENDIF(OPENGL_FOUND)
-
-ADD_LIBRARY(fltk_forms ${FLCPPFILES})
-INSTALL_TARGETS(/lib fltk_forms)
-TARGET_LINK_LIBRARIES(fltk_forms fltk)
-SET_TARGET_PROPERTIES(fltk_forms
- PROPERTIES
- VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
- SOVERSION ${FLTK_VERSION_PATCH})
-
-ADD_LIBRARY(fltk_images ${IMGCPPFILES})
-INSTALL_TARGETS(/lib fltk_images)
-TARGET_LINK_LIBRARIES(fltk_images fltk ${FLTK_PNG_LIBRARIES}
- ${FLTK_JPEG_LIBRARIES} ${FLTK_ZLIB_LIBRARIES})
-SET_TARGET_PROPERTIES(fltk_images
- PROPERTIES
- VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
- SOVERSION ${FLTK_VERSION_PATCH})
-
+#IF(OPENGL_FOUND)
+# ADD_LIBRARY(fltk_gl ${GLCPPFILES})
+# INSTALL_TARGETS(/lib fltk_gl)
+# TARGET_LINK_LIBRARIES(fltk_gl fltk ${OPENGL_LIBRARIES})
+# SET_TARGET_PROPERTIES(fltk_gl
+# PROPERTIES
+# VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
+# SOVERSION ${FLTK_VERSION_PATCH})
+#ENDIF(OPENGL_FOUND)
+
+#ADD_LIBRARY(fltk_forms ${FLCPPFILES})
+#INSTALL_TARGETS(/lib fltk_forms)
+#TARGET_LINK_LIBRARIES(fltk_forms fltk)
+#SET_TARGET_PROPERTIES(fltk_forms
+# PROPERTIES
+# VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
+# SOVERSION ${FLTK_VERSION_PATCH})
+#
+#ADD_LIBRARY(fltk_images ${IMGCPPFILES})
+#INSTALL_TARGETS(/lib fltk_images)
+#TARGET_LINK_LIBRARIES(fltk_images fltk ${FLTK_PNG_LIBRARIES}
+# ${FLTK_JPEG_LIBRARIES} ${FLTK_ZLIB_LIBRARIES})
+#SET_TARGET_PROPERTIES(fltk_images
+# PROPERTIES
+# VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
+# SOVERSION ${FLTK_VERSION_PATCH})
+#
diff -upr /home/toby/development/svn/fltk/branch-1.3-r6970/src//filename_list.cxx src//filename_list.cxx
--- /home/toby/development/svn/fltk/branch-1.3-r6970/src//filename_list.cxx 2010-07-26 12:08:34.596829871 +0200
+++ src//filename_list.cxx 2010-07-26 12:10:34.343829872 +0200
@@ -77,8 +77,8 @@ int fl_filename_list(const char *d, dire
Fl_File_Sort_F *sort) {
#ifndef HAVE_SCANDIR
int n = scandir(d, list, 0, sort);
-#elif defined(HAVE_SCANDIR_POSIX)
- // POSIX (2008) defines the comparison function like this:
+#elif defined(__hpux) || defined(__CYGWIN__) || (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 10 )
+ // HP-UX, Cygwin and POSIX (2008) define the comparison function like this:
int n = scandir(d, list, 0, (int(*)(const dirent **, const dirent **))sort);
#elif defined(__osf__)
// OSF, DU 4.0x
diff -upr /home/toby/development/svn/fltk/branch-1.3-r6970/src//fl_font_xft.cxx src//fl_font_xft.cxx
--- /home/toby/development/svn/fltk/branch-1.3-r6970/src//fl_font_xft.cxx 2010-07-26 12:08:34.594829871 +0200
+++ src//fl_font_xft.cxx 2010-07-26 12:10:34.355829872 +0200
@@ -128,6 +128,8 @@ void fl_font(Fl_Font fnum, Fl_Fontsize s
fl_fontsize = f;
#if XFT_MAJOR < 2
fl_xfont = f->font->u.core.font;
+#else
+ fl_xfont = NULL; // invalidate
#endif // XFT_MAJOR < 2
fl_xftfont = (void*)f->font;
}
@@ -413,6 +415,19 @@ static XFontStruct* load_xfont_for_xft2(
default: name--; // no prefix, restore name
}
+ // map generic Xft names to customary XLFD faces
+ if (!strcmp(name, "sans")) {
+ name = "helvetica";
+ } else if (!strcmp(name, "mono")) {
+ name = "courier";
+ } else if (!strcmp(name, "serif")) {
+ name = "times";
+ } else if (!strcmp(name, "screen")) {
+ name = "lucidatypewriter";
+ } else if (!strcmp(name, "dingbats")) {
+ name = "zapf dingbats";
+ }
+
// first, we do a query with no prefered size, to see if the font exists at all
snprintf(xlfd, 128, "-*-*%s*-%s-%c-*--*-*-*-*-*-*-*-*", name, weight, slant); // make up xlfd style name
xgl_font = XLoadQueryFont(fl_display, xlfd);
diff -upr /home/toby/development/svn/fltk/branch-1.3-r6970/src//Fl_lock.cxx src//Fl_lock.cxx
--- /home/toby/development/svn/fltk/branch-1.3-r6970/src//Fl_lock.cxx 2009-05-31 13:06:24.000000000 +0200
+++ src//Fl_lock.cxx 2010-07-26 12:10:34.335829872 +0200
@@ -187,6 +187,7 @@ int Fl::awake(Fl_Awake_Handler func, voi
See also: \ref advanced_multithreading
*/
#ifdef WIN32
+# include <winsock2.h>
# include <windows.h>
# include <process.h>
# include <FL/x.H>

View File

@@ -235,6 +235,7 @@ l 0000 root sys $includedir/FL/Enumerations.h Enumerations.H
l 0000 root sys $includedir/FL/Fl.h Fl.H
l 0000 root sys $includedir/FL/Fl_Adjuster.h Fl_Adjuster.H
l 0000 root sys $includedir/FL/Fl_Bitmap.h Fl_Bitmap.H
l 0000 root sys $includedir/FL/Fl_BMP_Image.h Fl_BMP_Image.H
l 0000 root sys $includedir/FL/Fl_Box.h Fl_Box.H
l 0000 root sys $includedir/FL/Fl_Browser.h Fl_Browser.H
l 0000 root sys $includedir/FL/Fl_Browser_.h Fl_Browser_.H
@@ -257,6 +258,8 @@ l 0000 root sys $includedir/FL/Fl_Float_Input.h Fl_Float_Input.H
l 0000 root sys $includedir/FL/Fl_FormsBitmap.h Fl_FormsBitmap.H
l 0000 root sys $includedir/FL/Fl_FormsPixmap.h Fl_FormsPixmap.H
l 0000 root sys $includedir/FL/Fl_Free.h Fl_Free.H
l 0000 root sys $includedir/FL/Fl_GIF_Image.h Fl_GIF_Image.H
l 0000 root sys $includedir/FL/Fl_Gl_Window.h Fl_Gl_Window.H
l 0000 root sys $includedir/FL/Fl_Group.h Fl_Group.H
l 0000 root sys $includedir/FL/Fl_Help_Dialog.h Fl_Help_Dialog.H
l 0000 root sys $includedir/FL/Fl_Help_View.h Fl_Help_View.H
@@ -266,6 +269,7 @@ l 0000 root sys $includedir/FL/Fl_Hor_Nice_Slider.h Fl_Hor_Nice_Slider.H
l 0000 root sys $includedir/FL/Fl_Hor_Slider.h Fl_Hor_Slider.H
l 0000 root sys $includedir/FL/Fl_Hor_Value_Slider.h Fl_Hor_Value_Slider.H
l 0000 root sys $includedir/FL/Fl_Image.h Fl_Image.H
l 0000 root sys $includedir/FL/Fl_JPEG_Image.h Fl_JPEG_Image.H
l 0000 root sys $includedir/FL/Fl_Input.h Fl_Input.H
l 0000 root sys $includedir/FL/Fl_Input_.h Fl_Input_.H
l 0000 root sys $includedir/FL/Fl_Input_Choice.h Fl_Input_Choice.H
@@ -288,6 +292,8 @@ l 0000 root sys $includedir/FL/Fl_Output.h Fl_Output.H
l 0000 root sys $includedir/FL/Fl_Overlay_Window.h Fl_Overlay_Window.H
l 0000 root sys $includedir/FL/Fl_Pack.h Fl_Pack.H
l 0000 root sys $includedir/FL/Fl_Pixmap.h Fl_Pixmap.H
l 0000 root sys $includedir/FL/Fl_PNG_Image.h Fl_PNG_Image.H
l 0000 root sys $includedir/FL/Fl_PNM_Image.h Fl_PNM_Image.H
l 0000 root sys $includedir/FL/Fl_Positioner.h Fl_Positioner.H
l 0000 root sys $includedir/FL/Fl_Progress.h Fl_Progress.H
l 0000 root sys $includedir/FL/Fl_Radio_Button.h Fl_Radio_Button.H
@@ -329,6 +335,9 @@ l 0000 root sys $includedir/FL/fl_file_chooser.H Fl_File_Chooser.H
l 0000 root sys $includedir/FL/fl_message.h fl_message.H
l 0000 root sys $includedir/FL/fl_show_colormap.h fl_show_colormap.H
l 0000 root sys $includedir/FL/fl_show_input.h fl_show_input.H
l 0000 root sys $includedir/FL/forms.h forms.H
l 0000 root sys $includedir/FL/gl_draw.h gl_draw.H
l 0000 root sys $includedir/FL/glut.h glut.H
l 0000 root sys $includedir/FL/win32.h win32.H
l 0000 root sys $includedir/FL/x.h x.H
%system all

View File

@@ -1,8 +1,6 @@
IF(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)
include_regular_expression("[.][cxx|c|h]$")
SET(CPPFILES
set(CPPFILES
Fl.cxx
Fl_Adjuster.cxx
Fl_Bitmap.cxx
@@ -18,6 +16,7 @@ SET(CPPFILES
Fl_Clock.cxx
Fl_Color_Chooser.cxx
Fl_Counter.cxx
Fl_Device.cxx
Fl_Dial.cxx
Fl_Double_Window.cxx
Fl_File_Browser.cxx
@@ -40,10 +39,13 @@ SET(CPPFILES
Fl_Menu_add.cxx
Fl_Menu_global.cxx
Fl_Multi_Label.cxx
Fl_Native_File_Chooser.cxx
Fl_Overlay_Window.cxx
Fl_Pack.cxx
Fl_Paged_Device.cxx
Fl_Pixmap.cxx
Fl_Positioner.cxx
Fl_Printer.cxx
Fl_Preferences.cxx
Fl_Progress.cxx
Fl_Repeat_Button.cxx
@@ -55,6 +57,8 @@ SET(CPPFILES
Fl_Shared_Image.cxx
Fl_Single_Window.cxx
Fl_Slider.cxx
Fl_Table.cxx
Fl_Table_Row.cxx
Fl_Tabs.cxx
Fl_Text_Buffer.cxx
Fl_Text_Display.cxx
@@ -62,6 +66,10 @@ SET(CPPFILES
Fl_Tile.cxx
Fl_Tiled_Image.cxx
Fl_Tooltip.cxx
Fl_Tree.cxx
Fl_Tree_Item_Array.cxx
Fl_Tree_Item.cxx
Fl_Tree_Prefs.cxx
Fl_Valuator.cxx
Fl_Value_Input.cxx
Fl_Value_Output.cxx
@@ -128,21 +136,25 @@ SET(CPPFILES
fl_show_colormap.cxx
fl_symbols.cxx
fl_vertex.cxx
ps_image.cxx
screen_xywh.cxx
fl_utf8.cxx
fl_encoding_latin1.cxx
fl_encoding_mac_roman.cxx
)
SET(FLCPPFILES
)
set(FLCPPFILES
forms_compatability.cxx
forms_bitmap.cxx
forms_free.cxx
forms_fselect.cxx
forms_pixmap.cxx
forms_timer.cxx
)
SET(GLCPPFILES
)
set(GLCPPFILES
Fl_Gl_Choice.cxx
Fl_Gl_Device_Plugin.cxx
Fl_Gl_Overlay.cxx
Fl_Gl_Window.cxx
freeglut_geometry.cxx
@@ -153,8 +165,9 @@ SET(GLCPPFILES
gl_start.cxx
glut_compatability.cxx
glut_font.cxx
)
SET(IMGCPPFILES
)
set(IMGCPPFILES
fl_images_core.cxx
Fl_BMP_Image.cxx
Fl_File_Icon2.cxx
@@ -163,10 +176,9 @@ SET(IMGCPPFILES
Fl_JPEG_Image.cxx
Fl_PNG_Image.cxx
Fl_PNM_Image.cxx
)
)
SET(CFILES
fl_call_main.c
set(CFILES
flstring.c
scandir.c
numericsort.c
@@ -179,45 +191,162 @@ SET(CFILES
xutf8/utf8Wrap.c
xutf8/keysym2Ucs.c
fl_utf.c
)
)
ADD_LIBRARY(fltk ${CPPFILES} ${CFILES})
INSTALL_TARGETS(/lib fltk)
SET_TARGET_PROPERTIES(fltk
PROPERTIES
VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
SOVERSION ${FLTK_VERSION_PATCH})
if(APPLE)
set_source_files_properties(
Fl.cxx Fl_Native_File_Chooser.cxx Fl_Printer.cxx
PROPERTIES COMPILE_FLAGS "-x objective-c++")
endif(APPLE)
TARGET_LINK_LIBRARIES(fltk ${FLTK_PLATFORM_DEPENDENT_LIBS} ${CMAKE_THREAD_LIBS_INIT})
#######################################################################
add_library(fltk STATIC ${CPPFILES} ${CFILES} fl_call_main.c)
set_target_properties(fltk PROPERTIES CLEAN_DIRECT_OUTPUT 1)
if(MSVC)
if(OPTION_LARGE_FILE)
set_target_properties(fltk PROPERTIES LINK_FLAGS /LARGEADDRESSAWARE)
endif()
set_target_properties(fltk
PROPERTIES
OUTPUT_NAME fltk
DEBUG_OUTPUT_NAME fltkd
)
endif(MSVC)
IF(X11_FOUND)
TARGET_LINK_LIBRARIES(fltk ${X11_LIBRARIES})
ENDIF(X11_FOUND)
if(USE_THREADS)
target_link_libraries(fltk ${CMAKE_THREAD_LIBS_INIT})
endif(USE_THREADS)
#IF(OPENGL_FOUND)
# ADD_LIBRARY(fltk_gl ${GLCPPFILES})
# INSTALL_TARGETS(/lib fltk_gl)
# TARGET_LINK_LIBRARIES(fltk_gl fltk ${OPENGL_LIBRARIES})
# SET_TARGET_PROPERTIES(fltk_gl
# PROPERTIES
# VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
# SOVERSION ${FLTK_VERSION_PATCH})
#ENDIF(OPENGL_FOUND)
if(USE_X11)
target_link_libraries(fltk ${X11_LIBRARIES})
endif(USE_X11)
#ADD_LIBRARY(fltk_forms ${FLCPPFILES})
#INSTALL_TARGETS(/lib fltk_forms)
#TARGET_LINK_LIBRARIES(fltk_forms fltk)
#SET_TARGET_PROPERTIES(fltk_forms
# PROPERTIES
# VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
# SOVERSION ${FLTK_VERSION_PATCH})
#
#ADD_LIBRARY(fltk_images ${IMGCPPFILES})
#INSTALL_TARGETS(/lib fltk_images)
#TARGET_LINK_LIBRARIES(fltk_images fltk ${FLTK_PNG_LIBRARIES}
# ${FLTK_JPEG_LIBRARIES} ${FLTK_ZLIB_LIBRARIES})
#SET_TARGET_PROPERTIES(fltk_images
# PROPERTIES
# VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
# SOVERSION ${FLTK_VERSION_PATCH})
#
if(WIN32)
target_link_libraries(fltk comctl32)
endif(WIN32)
if(HAVE_CAIRO)
target_link_libraries(fltk fltk_cairo ${PKG_CAIRO_LIBRARIES})
ENDif(HAVE_CAIRO)
if(USE_XINERAMA)
target_link_libraries(fltk ${X11_Xinerama_LIB})
endif(USE_XINERAMA)
if(USE_XFT)
target_link_libraries(fltk ${X11_Xft_LIB})
endif(USE_XFT)
if(LIB_fontconfig)
target_link_libraries(fltk ${LIB_fontconfig})
endif(LIB_fontconfig)
#######################################################################
#######################################################################
install(TARGETS fltk
EXPORT fltk-install
DESTINATION ${PREFIX_LIB}
)
#######################################################################
#######################################################################
if(OPTION_BUILD_SHARED_LIBS)
#######################################################################
add_library(fltk_SHARED SHARED ${CPPFILES} ${CFILES})
set_target_properties(fltk_SHARED
PROPERTIES CLEAN_DIRECT_OUTPUT 1
VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
SOVERSION ${FLTK_VERSION_PATCH}
)
if(MSVC)
set_target_properties(fltk_SHARED
PROPERTIES
OUTPUT_NAME fltkdll
DEBUG_OUTPUT_NAME fltkdlld
COMPILE_DEFINITIONS "FL_DLL;FL_LIBRARY"
)
if(OPTION_LARGE_FILE)
set_target_properties(fltk_SHARED PROPERTIES LINK_FLAGS /LARGEADDRESSAWARE)
endif(OPTION_LARGE_FILE)
else()
set_target_properties(fltk_SHARED PROPERTIES OUTPUT_NAME fltk)
endif(MSVC)
if(USE_THREADS)
target_link_libraries(fltk_SHARED ${CMAKE_THREAD_LIBS_INIT})
endif(USE_THREADS)
if(USE_X11)
target_link_libraries(fltk_SHARED ${X11_LIBRARIES})
endif(USE_X11)
if(WIN32)
target_link_libraries(fltk_SHARED comctl32)
endif(WIN32)
if(HAVE_CAIRO)
target_link_libraries(fltk_SHARED fltk_cairo ${PKG_CAIRO_LIBRARIES})
ENDif(HAVE_CAIRO)
if(USE_XINERAMA)
target_link_libraries(fltk_SHARED ${X11_Xinerama_LIB})
endif(USE_XINERAMA)
if(USE_XFT)
target_link_libraries(fltk_SHARED ${X11_Xft_LIB})
endif(USE_XFT)
if(LIB_fontconfig)
target_link_libraries(fltk_SHARED ${LIB_fontconfig})
endif(LIB_fontconfig)
#######################################################################
if(USE_THREADS)
target_link_libraries(fltk_SHARED ${CMAKE_THREAD_LIBS_INIT})
endif(USE_THREADS)
if(USE_X11)
target_link_libraries(fltk_SHARED ${X11_LIBRARIES})
endif(USE_X11)
#######################################################################
#######################################################################
install(TARGETS fltk_SHARED
EXPORT fltk-install
DESTINATION ${PREFIX_LIB}
)
#######################################################################
if(OPENGL_FOUND)
add_library(fltk_gl_SHARED SHARED ${GLCPPFILES})
target_link_libraries(fltk_gl_SHARED fltk ${OPENGL_LIBRARIES})
set_target_properties(fltk_gl_SHARED
PROPERTIES CLEAN_DIRECT_OUTPUT 1
VERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
SOVERSION ${FLTK_VERSION_PATCH}
)
if(MSVC)
set_target_properties(fltk_gl_SHARED
PROPERTIES
OUTPUT_NAME fltkgldll
DEBUG_OUTPUT_NAME fltkgldlld
COMPILE_DEFINITIONS "FL_DLL;FL_LIBRARY"
)
if(OPTION_LARGE_FILE)
set_target_properties(fltk_gl_SHARED PROPERTIES LINK_FLAGS /LARGEADDRESSAWARE)
endif(OPTION_LARGE_FILE)
else()
set_target_properties(fltk_gl_SHARED PROPERTIES OUTPUT_NAME fltk_gl)
endif(MSVC)
install(TARGETS fltk_gl_SHARED
EXPORT fltk-install
DESTINATION ${PREFIX_LIB}
)
endif(OPENGL_FOUND)
endif(OPTION_BUILD_SHARED_LIBS)

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl.cxx 6836 2009-07-25 12:56:16Z AlbrechtS $"
// "$Id: Fl.cxx 7354 2010-03-29 11:07:29Z matt $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
@@ -40,9 +40,13 @@
#include <stdlib.h>
#include "flstring.h"
#ifdef DEBUG
#if defined(__APPLE__)
#import <Cocoa/Cocoa.h>
#endif
#if defined(DEBUG) || defined(DEBUG_WATCH)
# include <stdio.h>
#endif // DEBUG
#endif // DEBUG || DEBUG_WATCH
#ifdef WIN32
# include <ole2.h>
@@ -406,10 +410,13 @@ double Fl::wait(double time_to_wait) {
// the idle function may turn off idle, we can then wait:
if (idle) time_to_wait = 0.0;
}
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
flush();
if (idle && !in_idle) // 'idle' may have been set within flush()
time_to_wait = 0.0;
return fl_wait(time_to_wait);
double retval = fl_wait(time_to_wait);
[pool release];
return retval;
#else
@@ -586,12 +593,13 @@ Fl_Window* fl_find(Window xid) {
Fl_X *window;
for (Fl_X **pp = &Fl_X::first; (window = *pp); pp = &window->next)
#if defined(WIN32) || defined(USE_X11)
if (window->xid == xid) {
if (window->xid == xid)
#elif defined(__APPLE_QUARTZ__)
if (window->xid == xid && !window->w->window()) {
if (window->xid == xid && !window->w->window())
#else
# error unsupported platform
#endif // __APPLE__
{
if (window != Fl_X::first && !Fl::modal()) {
// make this window be first to speed up searches
// this is not done if modal is true to avoid messing up modal stack
@@ -704,7 +712,7 @@ static handler_link *handlers = 0;
zero from its handle() method. Exactly which ones may change
in future versions, however.
*/
void Fl::add_handler(int (*ha)(int)) {
void Fl::add_handler(Fl_Event_Handler ha) {
handler_link *l = new handler_link;
l->handle = ha;
l->next = handlers;
@@ -714,7 +722,7 @@ void Fl::add_handler(int (*ha)(int)) {
/**
Removes a previously added event handler.
*/
void Fl::remove_handler(int (*ha)(int)) {
void Fl::remove_handler(Fl_Event_Handler ha) {
handler_link *l, *p;
// Search for the handler in the list...
@@ -1278,7 +1286,7 @@ int Fl_Window::handle(int ev)
#if defined(USE_X11) || defined(WIN32)
XMapWindow(fl_display, fl_xid(this)); // extra map calls are harmless
#elif defined(__APPLE_QUARTZ__)
MacMapWindow(this, fl_xid(this));
MacMapWindow(this, i->xid);
#else
# error unsupported platform
#endif // __APPLE__
@@ -1300,7 +1308,7 @@ int Fl_Window::handle(int ev)
#if defined(USE_X11) || defined(WIN32)
XUnmapWindow(fl_display, fl_xid(this));
#elif defined(__APPLE_QUARTZ__)
MacUnmapWindow(this, fl_xid(this));
MacUnmapWindow(this, i->xid);
#else
# error platform unsupported
#endif
@@ -1453,10 +1461,15 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) {
CombineRgn(i->region, i->region, R, RGN_OR);
XDestroyRegion(R);
#elif defined(__APPLE_QUARTZ__)
Fl_Region R = NewRgn();
SetRectRgn(R, X, Y, X+W, Y+H);
UnionRgn(R, i->region, i->region);
DisposeRgn(R);
CGRect arg = fl_cgrectmake_cocoa(X, Y, W, H);
int j; // don't add a rectangle totally inside the Fl_Region
for(j = 0; j < i->region->count; j++) {
if(CGRectContainsRect(i->region->rects[j], arg)) break;
}
if( j >= i->region->count) {
i->region->rects = (CGRect*)realloc(i->region->rects, (++(i->region->count)) * sizeof(CGRect));
i->region->rects[i->region->count - 1] = arg;
}
#else
# error unsupported platform
#endif
@@ -1480,7 +1493,7 @@ void Fl_Window::flush() {
#ifdef WIN32
# include "Fl_win32.cxx"
#elif defined(__APPLE__)
# include "Fl_mac.cxx"
# include "Fl_cocoa.mm"
#endif
//
@@ -1612,11 +1625,11 @@ void Fl::watch_widget_pointer(Fl_Widget *&w)
widget_watch = (Fl_Widget***)realloc(widget_watch, sizeof(Fl_Widget**)*max_widget_watch);
}
widget_watch[num_widget_watch++] = wp;
#ifdef DEBUG
#ifdef DEBUG_WATCH
printf ("\nwatch_widget_pointer: (%d/%d) %8p => %8p\n",
num_widget_watch,num_widget_watch,wp,*wp);
fflush(stdout);
#endif // DEBUG
#endif // DEBUG_WATCH
}
/**
@@ -1638,18 +1651,18 @@ void Fl::release_widget_pointer(Fl_Widget *&w)
if (j<i) widget_watch[j] = widget_watch[i]; // fill gap
j++;
}
#ifdef DEBUG
#ifdef DEBUG_WATCH
else { // found widget pointer
printf ("release_widget_pointer: (%d/%d) %8p => %8p\n",
i+1,num_widget_watch,wp,*wp);
}
#endif //DEBUG
#endif //DEBUG_WATCH
}
num_widget_watch = j;
#ifdef DEBUG
#ifdef DEBUG_WATCH
printf (" num_widget_watch = %d\n\n",num_widget_watch);
fflush(stdout);
#endif // DEBUG
#endif // DEBUG_WATCH
return;
}
/**
@@ -1699,5 +1712,5 @@ Fl_Widget_Tracker::~Fl_Widget_Tracker() {
}
//
// End of "$Id: Fl.cxx 6836 2009-07-25 12:56:16Z AlbrechtS $".
// End of "$Id: Fl.cxx 7354 2010-03-29 11:07:29Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Adjuster.cxx 6616 2009-01-01 21:28:26Z matt $"
// "$Id: Fl_Adjuster.cxx 7115 2010-02-20 17:40:07Z AlbrechtS $"
//
// Adjuster widget for the Fast Light Tool Kit (FLTK).
//
@@ -69,6 +69,7 @@ int Fl_Adjuster::handle(int event) {
double v;
int delta;
int mx = Fl::event_x();
// Fl_Widget_Tracker wp(this);
switch (event) {
case FL_PUSH:
if (Fl::visible_focus()) Fl::focus(this);
@@ -77,7 +78,10 @@ int Fl_Adjuster::handle(int event) {
drag = 3*(mx-x())/w() + 1;
else
drag = 3-3*(Fl::event_y()-y()-1)/h();
handle_push();
{ Fl_Widget_Tracker wp(this);
handle_push();
if (wp.deleted()) return 1;
}
redraw();
return 1;
case FL_DRAG:
@@ -98,9 +102,9 @@ int Fl_Adjuster::handle(int event) {
delta = 0;
}
switch (drag) {
case 3: v = increment(previous_value(), delta); break;
case 2: v = increment(previous_value(), delta*10); break;
default:v = increment(previous_value(), delta*100); break;
case 3: v = increment(previous_value(), delta); break;
case 2: v = increment(previous_value(), delta*10); break;
default:v = increment(previous_value(), delta*100); break;
}
handle_drag(soft() ? softclamp(v) : clamp(v));
return 1;
@@ -109,11 +113,13 @@ int Fl_Adjuster::handle(int event) {
if (Fl::event_state()&0xF0000) delta = -10;
else delta = 10;
switch (drag) {
case 3: v = increment(previous_value(), delta); break;
case 2: v = increment(previous_value(), delta*10); break;
default:v = increment(previous_value(), delta*100); break;
case 3: v = increment(previous_value(), delta); break;
case 2: v = increment(previous_value(), delta*10); break;
default:v = increment(previous_value(), delta*100); break;
}
Fl_Widget_Tracker wp(this);
handle_drag(soft() ? softclamp(v) : clamp(v));
if (wp.deleted()) return 1;
}
drag = 0;
redraw();
@@ -172,5 +178,5 @@ Fl_Adjuster::Fl_Adjuster(int X, int Y, int W, int H, const char* l)
}
//
// End of "$Id: Fl_Adjuster.cxx 6616 2009-01-01 21:28:26Z matt $".
// End of "$Id: Fl_Adjuster.cxx 7115 2010-02-20 17:40:07Z AlbrechtS $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Bitmap.cxx 6616 2009-01-01 21:28:26Z matt $"
// "$Id: Fl_Bitmap.cxx 7659 2010-07-01 13:21:32Z manolo $"
//
// Bitmap drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -37,9 +37,12 @@
#include <FL/Fl_Widget.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Bitmap.H>
#include <FL/Fl_Printer.H>
#include "flstring.h"
#if defined(__APPLE_QUARTZ__)
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
@@ -51,14 +54,18 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
*dst++ = ((reverse[*src & 0x0f] & 0xf0) | (reverse[(*src >> 4) & 0x0f] & 0x0f))^0xff;
}
CGDataProviderRef srcp = CGDataProviderCreateWithData( 0L, bmask, rowBytes*h, 0L);
CGImageRef id = CGImageMaskCreate( w, h, 1, 1, rowBytes, srcp, 0L, false);
CGImageRef id_ = CGImageMaskCreate( w, h, 1, 1, rowBytes, srcp, 0L, false);
CGDataProviderRelease(srcp);
return (Fl_Bitmask)id;
return (Fl_Bitmask)id_;
}
void fl_delete_bitmask(Fl_Bitmask id) {
if (id) CGImageRelease((CGImageRef)id);
void fl_delete_bitmask(Fl_Bitmask bm) {
if (bm) CGImageRelease((CGImageRef)bm);
}
#elif defined(WIN32) // Windows bitmask functions...
// 'fl_create_bitmap()' - Create a 1-bit bitmap for drawing...
static Fl_Bitmask fl_create_bitmap(int w, int h, const uchar *data) {
// we need to pad the lines out to words & swap the bits
@@ -68,7 +75,7 @@ static Fl_Bitmask fl_create_bitmap(int w, int h, const uchar *data) {
uchar* newarray = new uchar[w2*h];
const uchar* src = data;
uchar* dest = newarray;
Fl_Bitmask id;
Fl_Bitmask bm;
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };
@@ -80,18 +87,18 @@ static Fl_Bitmask fl_create_bitmap(int w, int h, const uchar *data) {
dest += w2-w1;
}
id = CreateBitmap(w, h, 1, 1, newarray);
bm = CreateBitmap(w, h, 1, 1, newarray);
delete[] newarray;
return id;
return bm;
}
// 'fl_create_bitmask()' - Create an N-bit bitmap for masking...
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
// this won't work when the user changes display mode during run or
// has two screens with differnet depths
Fl_Bitmask id;
Fl_Bitmask bm;
static uchar hiNibble[16] =
{ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0 };
@@ -140,45 +147,21 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
dst += pad;
}
id = CreateBitmap(w, h, np, bpp, newarray);
bm = CreateBitmap(w, h, np, bpp, newarray);
delete[] newarray;
return id;
return bm;
}
#if 0 // This doesn't appear to be used anywhere...
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data, int for_mask) {
// we need to pad the lines out to words & swap the bits
// in each byte.
int w1 = (w+7)/8;
int w2 = ((w+15)/16)*2;
uchar* newarray = new uchar[w2*h];
const uchar* src = data;
uchar* dest = newarray;
Fl_Bitmask id;
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };
for (int y=0; y < h; y++) {
for (int n = 0; n < w1; n++, src++)
*dest++ = (reverse[*src & 0x0f] & 0xf0) |
(reverse[(*src >> 4) & 0x0f] & 0x0f);
dest += w2-w1;
}
id = CreateBitmap(w, h, 1, 1, newarray);
delete[] newarray;
return (id);
}
# endif // 0
void fl_delete_bitmask(Fl_Bitmask bm) {
DeleteObject((HGDIOBJ)bm);
}
#else // X11 bitmask functions
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
return XCreateBitmapFromData(fl_display, fl_window, (const char *)data,
(w+7)&-8, h);
@@ -187,12 +170,14 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
void fl_delete_bitmask(Fl_Bitmask bm) {
fl_delete_offscreen((Fl_Offscreen)bm);
}
#endif // __APPLE__
// Create a 1-bit mask used for alpha blending
Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array) {
Fl_Bitmask mask;
Fl_Bitmask bm;
int bmw = (w + 7) / 8;
uchar *bitmap = new uchar[bmw * h];
uchar *bitptr, bit;
@@ -257,62 +242,133 @@ Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array)
}
}
mask = fl_create_bitmask(w, h, bitmap);
bm = fl_create_bitmask(w, h, bitmap);
delete[] bitmap;
return (mask);
return (bm);
}
void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
if (!array) {
draw_empty(XP, YP);
return;
}
fl_graphics_driver->draw(this, XP, YP, WP, HP, cx, cy);
}
static int start(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int w, int h, int &cx, int &cy,
int &X, int &Y, int &W, int &H)
{
// account for current clip region (faster on Irix):
int X,Y,W,H; fl_clip_box(XP,YP,WP,HP,X,Y,W,H);
fl_clip_box(XP,YP,WP,HP,X,Y,W,H);
cx += X-XP; cy += Y-YP;
// clip the box down to the size of image, quit if empty:
if (cx < 0) {W += cx; X -= cx; cx = 0;}
if ((cx+W) > w()) W = w()-cx;
if (W <= 0) return;
if (cx+W > w) W = w-cx;
if (W <= 0) return 1;
if (cy < 0) {H += cy; Y -= cy; cy = 0;}
if ((cy+H) > h()) H = h()-cy;
if (H <= 0) return;
if (cy+H > h) H = h-cy;
if (H <= 0) return 1;
return 0;
}
#if defined(USE_X11)
if (!id) id = fl_create_bitmask(w(), h(), array);
#ifdef __APPLE__
void Fl_Quartz_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
if (!bm->array) {
bm->draw_empty(XP, YP);
return;
}
if (start(bm, XP, YP, WP, HP, bm->w(), bm->h(), cx, cy, X, Y, W, H)) {
return;
}
if (!bm->id_) bm->id_ = fl_create_bitmask(bm->w(), bm->h(), bm->array);
if (bm->id_ && fl_gc) {
CGRect rect = { { X, Y }, { W, H } };
Fl_X::q_begin_image(rect, cx, cy, bm->w(), bm->h());
CGContextDrawImage(fl_gc, rect, (CGImageRef)bm->id_);
Fl_X::q_end_image();
}
}
XSetStipple(fl_display, fl_gc, id);
int ox = X-cx; if (ox < 0) ox += w();
int oy = Y-cy; if (oy < 0) oy += h();
#elif defined(WIN32)
void Fl_GDI_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
if (!bm->array) {
bm->draw_empty(XP, YP);
return;
}
if (start(bm, XP, YP, WP, HP, bm->w(), bm->h(), cx, cy, X, Y, W, H)) {
return;
}
if (!bm->id_) bm->id_ = fl_create_bitmap(bm->w(), bm->h(), bm->array);
typedef BOOL (WINAPI* fl_transp_func) (HDC,int,int,int,int,HDC,int,int,int,int,UINT);
static fl_transp_func fl_TransparentBlt;
HDC tempdc;
int save;
BOOL use_print_algo = false;
if (fl_surface->type() == Fl_Printer::device_type) {
static HMODULE hMod = NULL;
if (!hMod) {
hMod = LoadLibrary("MSIMG32.DLL");
if (hMod) fl_TransparentBlt = (fl_transp_func)GetProcAddress(hMod, "TransparentBlt");
}
if (hMod) use_print_algo = true;
}
if (use_print_algo) { // algorithm for bitmap output to Fl_GDI_Printer
Fl_Offscreen tmp_id = fl_create_offscreen(W, H);
fl_begin_offscreen(tmp_id);
Fl_Color save_c = fl_color(); // save bitmap's desired color
uchar r, g, b;
Fl::get_color(save_c, r, g, b);
r = 255-r;
g = 255-g;
b = 255-b;
Fl_Color background = fl_rgb_color(r, g, b); // a color very different from the bitmap's
fl_color(background);
fl_rectf(0,0,W,H); // use this color as offscreen background
fl_color(save_c); // back to bitmap's color
tempdc = CreateCompatibleDC(fl_gc);
save = SaveDC(tempdc);
SelectObject(tempdc, (HGDIOBJ)bm->id_);
SelectObject(fl_gc, fl_brush()); // use bitmap's desired color
BitBlt(fl_gc, 0, 0, W, H, tempdc, 0, 0, 0xE20746L); // draw bitmap to offscreen
fl_end_offscreen(); // offscreen data is in tmp_id
SelectObject(tempdc, (HGDIOBJ)tmp_id); // use offscreen data
// draw it to printer context with background color as transparent
fl_TransparentBlt(fl_gc, X,Y,W,H, tempdc, cx, cy, bm->w(), bm->h(), RGB(r, g, b) );
fl_delete_offscreen(tmp_id);
}
else { // algorithm for bitmap output to display
tempdc = CreateCompatibleDC(fl_gc);
save = SaveDC(tempdc);
SelectObject(tempdc, (HGDIOBJ)bm->id_);
SelectObject(fl_gc, fl_brush());
// secret bitblt code found in old MSWindows reference manual:
BitBlt(fl_gc, X, Y, W, H, tempdc, cx, cy, 0xE20746L);
}
RestoreDC(tempdc, save);
DeleteDC(tempdc);
}
#else // Xlib
void Fl_Xlib_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
if (!bm->array) {
bm->draw_empty(XP, YP);
return;
}
if (start(bm, XP, YP, WP, HP, bm->w(), bm->h(), cx, cy, X, Y, W, H)) {
return;
}
if (!bm->id_) bm->id_ = fl_create_bitmask(bm->w(), bm->h(), bm->array);
XSetStipple(fl_display, fl_gc, bm->id_);
int ox = X-cx; if (ox < 0) ox += bm->w();
int oy = Y-cy; if (oy < 0) oy += bm->h();
XSetTSOrigin(fl_display, fl_gc, ox, oy);
XSetFillStyle(fl_display, fl_gc, FillStippled);
XFillRectangle(fl_display, fl_window, fl_gc, X, Y, W, H);
XSetFillStyle(fl_display, fl_gc, FillSolid);
#elif defined(WIN32)
if (!id) id = fl_create_bitmap(w(), h(), array);
HDC tempdc = CreateCompatibleDC(fl_gc);
int save = SaveDC(tempdc);
SelectObject(tempdc, (HGDIOBJ)id);
SelectObject(fl_gc, fl_brush());
// secret bitblt code found in old MSWindows reference manual:
BitBlt(fl_gc, X, Y, W, H, tempdc, cx, cy, 0xE20746L);
RestoreDC(tempdc, save);
DeleteDC(tempdc);
#elif defined(__APPLE_QUARTZ__)
if (!id) id = fl_create_bitmask(w(), h(), array);
if (id && fl_gc) {
CGRect rect = { { X, Y }, { W, H } };
Fl_X::q_begin_image(rect, cx, cy, w(), h());
CGContextDrawImage(fl_gc, rect, (CGImageRef)id);
Fl_X::q_end_image();
}
#else
# error unsupported platform
#endif
}
#endif
/**
The destructor free all memory and server resources that are used by
@@ -324,9 +380,13 @@ Fl_Bitmap::~Fl_Bitmap() {
}
void Fl_Bitmap::uncache() {
if (id) {
fl_delete_bitmask((Fl_Offscreen)id);
id = 0;
if (id_) {
#ifdef __APPLE_QUARTZ__
fl_delete_bitmask((Fl_Bitmask)id_);
#else
fl_delete_bitmask((Fl_Offscreen)id_);
#endif
id_ = 0;
}
}
@@ -418,5 +478,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
//
// End of "$Id: Fl_Bitmap.cxx 6616 2009-01-01 21:28:26Z matt $".
// End of "$Id: Fl_Bitmap.cxx 7659 2010-07-01 13:21:32Z manolo $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Browser_.cxx 6737 2009-04-02 06:44:34Z greg.ercolano $"
// "$Id: Fl_Browser_.cxx 7115 2010-02-20 17:40:07Z AlbrechtS $"
//
// Base Browser widget class for the Fast Light Tool Kit (FLTK).
//
@@ -678,11 +678,15 @@ int Fl_Browser_::deselect(int docallbacks) {
int Fl_Browser_::select_only(void* item, int docallbacks) {
if (!item) return deselect(docallbacks);
int change = 0;
Fl_Widget_Tracker wp(this);
if (type() == FL_MULTI_BROWSER) {
for (void* p = item_first(); p; p = item_next(p))
for (void* p = item_first(); p; p = item_next(p)) {
if (p != item) change |= select(p, 0, docallbacks);
if (wp.deleted()) return change;
}
}
change |= select(item, 1, docallbacks);
if (wp.deleted()) return change;
display(item);
return change;
}
@@ -693,6 +697,20 @@ int Fl_Browser_::select_only(void* item, int docallbacks) {
\returns 1 if event was processed, 0 if not.
*/
int Fl_Browser_::handle(int event) {
// NOTE:
// We use Fl_Widget_Tracker to test if the user has deleted
// this widget in a callback. Callbacks can be called by:
// - do_callback()
// - select()
// - select_only()
// - deselect()
// Thus we must test wp.deleted() after each of these calls,
// unless we return directly after one of these.
// If wp.deleted() is true, we return 1 because we used the event.
Fl_Widget_Tracker wp(this);
// must do shortcuts first or the scrollbar will get them...
if (event == FL_ENTER || event == FL_LEAVE) return 1;
if (event == FL_KEYBOARD && type() >= FL_HOLD_BROWSER) {
@@ -706,8 +724,12 @@ int Fl_Browser_::handle(int event) {
if (item_height(l)>0) {select_only(l, when()); break;}
return 1;
case FL_Up:
while ((l = item_prev(l))) if (item_height(l)>0) {
select_only(l, when()); break;}
while ((l = item_prev(l))) {
if (item_height(l)>0) {
select_only(l, when());
break; // no need to test wp (return 1)
}
}
return 1;
}
} else {
@@ -715,6 +737,7 @@ int Fl_Browser_::handle(int event) {
case FL_Enter:
case FL_KP_Enter:
select_only(l, when() & ~FL_WHEN_ENTER_KEY);
if (wp.deleted()) return 1;
if (when() & FL_WHEN_ENTER_KEY) {
set_changed();
do_callback();
@@ -728,6 +751,7 @@ int Fl_Browser_::handle(int event) {
while ((l = item_next(l))) {
if (Fl::event_state(FL_SHIFT|FL_CTRL))
select(l, l1 ? item_selected(l1) : 1, when());
if (wp.deleted()) return 1;
if (item_height(l)>0) goto J1;
}
return 1;
@@ -735,6 +759,7 @@ int Fl_Browser_::handle(int event) {
while ((l = item_prev(l))) {
if (Fl::event_state(FL_SHIFT|FL_CTRL))
select(l, l1 ? item_selected(l1) : 1, when());
if (wp.deleted()) return 1;
if (item_height(l)>0) goto J1;
}
return 1;
@@ -749,6 +774,8 @@ J1:
}
if (Fl_Group::handle(event)) return 1;
if (wp.deleted()) return 1;
int X, Y, W, H; bbox(X, Y, W, H);
int my;
// NOTE:
@@ -784,9 +811,11 @@ J1:
;
else if (type() != FL_MULTI_BROWSER) {
change = select_only(find_item(my), 0);
if (wp.deleted()) return 1;
if (change && (when() & FL_WHEN_CHANGED)) {
set_changed();
do_callback();
if (wp.deleted()) return 1;
}
} else {
void* l = find_item(my);
@@ -796,9 +825,11 @@ J1:
if (l) {
whichway = !item_selected(l);
change = select(l, whichway, 0);
if (wp.deleted()) return 1;
if (change && (when() & FL_WHEN_CHANGED)) {
set_changed();
do_callback();
if (wp.deleted()) return 1;
}
}
} else if (Fl::event_state(FL_SHIFT)) { // extend selection:
@@ -814,23 +845,29 @@ J1:
if (!m) {down = 0; break;}
}}
if (down) {
for (void* m = selection_; m != l; m = item_next(m))
for (void* m = selection_; m != l; m = item_next(m)) {
select(m, whichway, when() & FL_WHEN_CHANGED);
if (wp.deleted()) return 1;
}
} else {
void* e = selection_;
for (void* m = item_next(l); m; m = item_next(m)) {
select(m, whichway, when() & FL_WHEN_CHANGED);
if (wp.deleted()) return 1;
if (m == e) break;
}
}
// do the clicked item last so the select box is around it:
change = 1;
if (l) select(l, whichway, when() & FL_WHEN_CHANGED);
if (wp.deleted()) return 1;
} else { // select only this item
change = select_only(l, 0);
if (wp.deleted()) return 1;
if (change && (when() & FL_WHEN_CHANGED)) {
set_changed();
do_callback();
if (wp.deleted()) return 1;
}
}
}
@@ -863,10 +900,12 @@ J1:
for (; t && t != b; t = item_next(t)) {
char change_t;
change_t = select(t, whichway, 0);
if (wp.deleted()) return 1;
change |= change_t;
if (change_t && (when() & FL_WHEN_CHANGED)) {
set_changed();
do_callback();
if (wp.deleted()) return 1;
}
}
if (l) selection_ = l;
@@ -877,12 +916,16 @@ J1:
find_item(my);
change = (l != l1);
select_only(l, when() & FL_WHEN_CHANGED);
if (wp.deleted()) return 1;
}
py = my;
return 1;
case FL_RELEASE:
if (type() == FL_SELECT_BROWSER) {
void* t = selection_; deselect(); selection_ = t;
void* t = selection_;
deselect();
if (wp.deleted()) return 1;
selection_ = t;
}
if (change) {
set_changed();
@@ -890,7 +933,8 @@ J1:
} else {
if (when() & FL_WHEN_NOT_CHANGED) do_callback();
}
if (wp.deleted()) return 1;
// double click calls the callback: (like Enter Key)
if (Fl::event_clicks() && (when() & FL_WHEN_ENTER_KEY)) {
set_changed();
@@ -962,7 +1006,7 @@ void Fl_Browser_::sort(int flags) {
a = item_next(a);
n++;
}
for (i=n-1; i>0; i--) {
for (i=n; i>0; i--) {
char swapped = 0;
a = item_first();
b = item_next(a);
@@ -981,6 +1025,7 @@ void Fl_Browser_::sort(int flags) {
swapped = 1;
}
}
if (!c) break;
b = c; a = item_prev(b);
}
if (!swapped)
@@ -1058,5 +1103,5 @@ void Fl_Browser_::item_select(void *item, int val) {}
int Fl_Browser_::item_selected(void* item) const { return item==selection_ ? 1 : 0; }
//
// End of "$Id: Fl_Browser_.cxx 6737 2009-04-02 06:44:34Z greg.ercolano $".
// End of "$Id: Fl_Browser_.cxx 7115 2010-02-20 17:40:07Z AlbrechtS $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Button.cxx 6616 2009-01-01 21:28:26Z matt $"
// "$Id: Fl_Button.cxx 7476 2010-04-09 22:18:05Z matt $"
//
// Button widget for the Fast Light Tool Kit (FLTK).
//
@@ -60,7 +60,7 @@ int Fl_Button::value(int v) {
*/
void Fl_Button::setonly() { // set this radio button on, turn others off
value(1);
Fl_Group* g = (Fl_Group*)parent();
Fl_Group* g = parent();
Fl_Widget*const* a = g->array();
for (int i = g->children(); i--;) {
Fl_Widget* o = *a++;
@@ -72,6 +72,7 @@ void Fl_Button::draw() {
if (type() == FL_HIDDEN_BUTTON) return;
Fl_Color col = value() ? selection_color() : color();
draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(), col);
draw_backdrop();
if (labeltype() == FL_NORMAL_LABEL && value()) {
Fl_Color c = labelcolor();
labelcolor(fl_contrast(c, col));
@@ -84,7 +85,7 @@ void Fl_Button::draw() {
int Fl_Button::handle(int event) {
int newval;
switch (event) {
case FL_ENTER:
case FL_ENTER: /* FALLTHROUGH */
case FL_LEAVE:
// if ((value_?selection_color():color())==FL_GRAY) redraw();
return 1;
@@ -117,7 +118,11 @@ int Fl_Button::handle(int event) {
else {
value(oldval);
set_changed();
if (when() & FL_WHEN_CHANGED) do_callback();
if (when() & FL_WHEN_CHANGED) {
Fl_Widget_Tracker wp(this);
do_callback();
if (wp.deleted()) return 1;
}
}
if (when() & FL_WHEN_RELEASE) do_callback();
return 1;
@@ -139,7 +144,7 @@ int Fl_Button::handle(int event) {
do_callback();
} else if (when() & FL_WHEN_RELEASE) do_callback();
return 1;
case FL_FOCUS :
case FL_FOCUS : /* FALLTHROUGH */
case FL_UNFOCUS :
if (Fl::visible_focus()) {
if (box() == FL_NO_BOX) {
@@ -156,6 +161,7 @@ int Fl_Button::handle(int event) {
if (Fl::focus() == this && Fl::event_key() == ' ' &&
!(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META))) {
set_changed();
Fl_Widget_Tracker wp(this);
if (type() == FL_RADIO_BUTTON && !value_) {
setonly();
if (when() & FL_WHEN_CHANGED) do_callback();
@@ -163,6 +169,7 @@ int Fl_Button::handle(int event) {
value(!value());
if (when() & FL_WHEN_CHANGED) do_callback();
}
if (wp.deleted()) return 1;
if (when() & FL_WHEN_RELEASE) do_callback();
return 1;
}
@@ -186,5 +193,5 @@ Fl_Button::Fl_Button(int X, int Y, int W, int H, const char *L)
}
//
// End of "$Id: Fl_Button.cxx 6616 2009-01-01 21:28:26Z matt $".
// End of "$Id: Fl_Button.cxx 7476 2010-04-09 22:18:05Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Color_Chooser.cxx 6616 2009-01-01 21:28:26Z matt $"
// "$Id: Fl_Color_Chooser.cxx 7347 2010-03-27 16:35:14Z AlbrechtS $"
//
// Color chooser for the Fast Light Tool Kit (FLTK).
//
@@ -123,7 +123,7 @@ void Fl_Color_Chooser::set_valuators() {
gvalue.range(0,1); gvalue.step(1,1000); gvalue.value(g_);
bvalue.range(0,1); bvalue.step(1,1000); bvalue.value(b_);
break;
case M_BYTE:
case M_BYTE: /* FALLTHROUGH */
case M_HEX:
rvalue.range(0,255); rvalue.step(1); rvalue.value(int(255*r_+.5));
gvalue.range(0,255); gvalue.step(1); gvalue.value(int(255*g_+.5));
@@ -233,7 +233,7 @@ int Flcc_HueBox::handle(int e) {
if (Fl::event_state(FL_CTRL)) H = ih;
if (c->hsv(H, S, c->value())) c->do_callback();
} return 1;
case FL_FOCUS :
case FL_FOCUS : /* FALLTHROUGH */
case FL_UNFOCUS :
if (Fl::visible_focus()) {
redraw();
@@ -354,7 +354,7 @@ int Flcc_ValueBox::handle(int e) {
if (fabs(Yf-iv)<(3*1.0/h())) Yf = iv;
if (c->hsv(c->hue(),c->saturation(),Yf)) c->do_callback();
} return 1;
case FL_FOCUS :
case FL_FOCUS : /* FALLTHROUGH */
case FL_UNFOCUS :
if (Fl::visible_focus()) {
redraw();
@@ -516,7 +516,7 @@ void ColorChip::draw() {
h()-Fl::box_dh(box()),r,g,b);
}
static void chooser_cb(Fl_Object* o, void* vv) {
static void chooser_cb(Fl_Widget* o, void* vv) {
Fl_Color_Chooser* c = (Fl_Color_Chooser*)o;
ColorChip* v = (ColorChip*)vv;
v->r = uchar(255*c->r()+.5);
@@ -528,6 +528,27 @@ static void chooser_cb(Fl_Object* o, void* vv) {
extern const char* fl_ok;
extern const char* fl_cancel;
// fl_color_chooser's callback for ok_button (below)
// [in] o is a pointer to okay_button (below)
// [in] p is a pointer to an int to receive the return value (1)
// closes the fl_color_chooser window
static void cc_ok_cb (Fl_Widget *o, void *p) {
*((int *)p) = 1; // set return value
o->window()->hide();
}
// fl_color_chooser's callback for cancel_button and window close
// [in] o is a pointer to cancel_button (below) _or_ the dialog window
// [in] p is a pointer to an int to receive the return value (0)
// closes the fl_color_chooser window
static void cc_cancel_cb (Fl_Widget *o, void *p) {
*((int *)p) = 0; // set return value
if (o->window()) // cancel button
o->window()->hide();
else // window close
o->hide();
}
/** \addtogroup group_comdlg
@{ */
/**
@@ -541,15 +562,19 @@ extern const char* fl_cancel;
\relates Fl_Color_Chooser
*/
int fl_color_chooser(const char* name, double& r, double& g, double& b) {
int ret = 0;
Fl_Window window(215,200,name);
window.callback(cc_cancel_cb,&ret);
Fl_Color_Chooser chooser(10, 10, 195, 115);
ColorChip ok_color(10, 130, 95, 25);
Fl_Return_Button ok_button(10, 165, 95, 25, fl_ok);
ok_button.callback(cc_ok_cb,&ret);
ColorChip cancel_color(110, 130, 95, 25);
cancel_color.r = uchar(255*r+.5); ok_color.r = cancel_color.r;
ok_color.g = cancel_color.g = uchar(255*g+.5);
ok_color.b = cancel_color.b = uchar(255*b+.5);
Fl_Button cancel_button(110, 165, 95, 25, fl_cancel);
cancel_button.callback(cc_cancel_cb,&ret);
window.resizable(chooser);
chooser.rgb(r,g,b);
chooser.callback(chooser_cb, &ok_color);
@@ -557,21 +582,13 @@ int fl_color_chooser(const char* name, double& r, double& g, double& b) {
window.set_modal();
window.hotspot(window);
window.show();
while (window.shown()) {
Fl::wait();
for (;;) {
Fl_Widget* o = Fl::readqueue();
if (!o) break;
if (o == &ok_button) {
r = chooser.r();
g = chooser.g();
b = chooser.b();
return 1;
}
if (o == &window || o == &cancel_button) return 0;
}
while (window.shown()) Fl::wait();
if (ret) { // ok_button or Enter
r = chooser.r();
g = chooser.g();
b = chooser.b();
}
return 0;
return ret;
}
/**
@@ -598,5 +615,5 @@ int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b) {
}
/** @} */
//
// End of "$Id: Fl_Color_Chooser.cxx 6616 2009-01-01 21:28:26Z matt $".
// End of "$Id: Fl_Color_Chooser.cxx 7347 2010-03-27 16:35:14Z AlbrechtS $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Counter.cxx 6616 2009-01-01 21:28:26Z matt $"
// "$Id: Fl_Counter.cxx 7162 2010-02-26 21:10:46Z matt $"
//
// Counter widget for the Fast Light Tool Kit (FLTK).
//
@@ -137,14 +137,19 @@ int Fl_Counter::handle(int event) {
return 1;
case FL_PUSH:
if (Fl::visible_focus()) Fl::focus(this);
handle_push();
{ Fl_Widget_Tracker wp(this);
handle_push();
if (wp.deleted()) return 1;
}
case FL_DRAG:
i = calc_mouseobj();
if (i != mouseobj) {
Fl::remove_timeout(repeat_callback, this);
mouseobj = (uchar)i;
if (i) Fl::add_timeout(INITIALREPEAT, repeat_callback, this);
Fl_Widget_Tracker wp(this);
increment_cb();
if (wp.deleted()) return 1;
redraw();
}
return 1;
@@ -160,13 +165,13 @@ int Fl_Counter::handle(int event) {
return 0;
}
// break not required because of switch...
case FL_FOCUS :
case FL_FOCUS : /* FALLTHROUGH */
case FL_UNFOCUS :
if (Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
case FL_ENTER :
case FL_ENTER : /* FALLTHROUGH */
case FL_LEAVE :
return 1;
default:
@@ -202,5 +207,5 @@ Fl_Counter::Fl_Counter(int X, int Y, int W, int H, const char* L)
}
//
// End of "$Id: Fl_Counter.cxx 6616 2009-01-01 21:28:26Z matt $".
// End of "$Id: Fl_Counter.cxx 7162 2010-02-26 21:10:46Z matt $".
//

View File

@@ -0,0 +1,56 @@
//
// "$Id: Fl_Device.cxx 7659 2010-07-01 13:21:32Z manolo $"
//
// implementation of Fl_Device class for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to:
//
// http://www.fltk.org/str.php
//
#include <FL/Fl.H>
#include <FL/Fl_Device.H>
#include <FL/Fl_Image.H>
const char *Fl_Device::device_type = "Fl_Device";
const char *Fl_Surface_Device::device_type = "Fl_Surface_Device";
const char *Fl_Display_Device::device_type = "Fl_Display_Device";
const char *Fl_Graphics_Driver::device_type = "Fl_Graphics_Driver";
#if defined(__APPLE__) || defined(FL_DOXYGEN)
const char *Fl_Quartz_Graphics_Driver::device_type = "Fl_Quartz_Graphics_Driver";
#endif
#if defined(WIN32) || defined(FL_DOXYGEN)
const char *Fl_GDI_Graphics_Driver::device_type = "Fl_GDI_Graphics_Driver";
#endif
#if !(defined(__APPLE__) || defined(WIN32))
const char *Fl_Xlib_Graphics_Driver::device_type = "Fl_Xlib_Graphics_Driver";
#endif
/** \brief Use this drawing surface for future graphics requests. */
void Fl_Surface_Device::set_current(void)
{
fl_graphics_driver = _driver;
fl_surface = this;
}
//
// End of "$Id: Fl_Device.cxx 7659 2010-07-01 13:21:32Z manolo $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Dial.cxx 6616 2009-01-01 21:28:26Z matt $"
// "$Id: Fl_Dial.cxx 7162 2010-02-26 21:10:46Z matt $"
//
// Circular dial widget for the Fast Light Tool Kit (FLTK).
//
@@ -109,8 +109,10 @@ void Fl_Dial::draw() {
*/
int Fl_Dial::handle(int event, int X, int Y, int W, int H) {
switch (event) {
case FL_PUSH:
case FL_PUSH: {
Fl_Widget_Tracker wp(this);
handle_push();
if (wp.deleted()) return 1; }
case FL_DRAG: {
int mx = (Fl::event_x()-X-W/2)*H;
int my = (Fl::event_y()-Y-H/2)*W;
@@ -132,7 +134,7 @@ int Fl_Dial::handle(int event, int X, int Y, int W, int H) {
case FL_RELEASE:
handle_release();
return 1;
case FL_ENTER :
case FL_ENTER : /* FALLTHROUGH */
case FL_LEAVE :
return 1;
default:
@@ -160,5 +162,5 @@ Fl_Dial::Fl_Dial(int X, int Y, int W, int H, const char* l)
}
//
// End of "$Id: Fl_Dial.cxx 6616 2009-01-01 21:28:26Z matt $".
// End of "$Id: Fl_Dial.cxx 7162 2010-02-26 21:10:46Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Double_Window.cxx 6616 2009-01-01 21:28:26Z matt $"
// "$Id: Fl_Double_Window.cxx 7671 2010-07-09 17:31:33Z manolo $"
//
// Double-buffered window code for the Fast Light Tool Kit (FLTK).
//
@@ -28,6 +28,7 @@
#include <config.h>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Printer.H>
#include <FL/x.H>
#include <FL/fl_draw.H>
@@ -64,8 +65,28 @@ void Fl_Double_Window::show() {
Fl_Window::show();
}
static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
if( fl_graphics_driver == fl_display_device->driver()) {
fl_copy_offscreen_to_display(x, y, w, h, pixmap, srcx, srcy);
}
else { // when copy is not to the display
fl_begin_offscreen(pixmap);
uchar *img = fl_read_image(NULL, srcx, srcy, w, h, 0);
fl_end_offscreen();
fl_draw_image(img, x, y, w, h, 3, 0);
delete img;
}
}
#if defined(USE_X11)
static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y);
}
// maybe someone feels inclined to implement alpha blending on X11?
char fl_can_do_alpha_blending() {
return 0;
@@ -100,10 +121,9 @@ char fl_can_do_alpha_blending() {
fl_alpha_blend = (fl_alpha_blend_func)GetProcAddress(hMod, "AlphaBlend");
// give up if we can't find it (Win95)
if (!fl_alpha_blend) return 0;
// we have the call, but does our display support alpha blending?
HDC dc = 0L;//fl_gc;
// get the current or the desktop's device context
if (!dc) dc = GetDC(0L);
// we have the call, but does our display support alpha blending?
// get the desktop's device context
HDC dc = GetDC(0L);
if (!dc) return 0;
// check the device capabilities flags. However GetDeviceCaps
// does not return anything useful, so we have to do it manually:
@@ -117,8 +137,8 @@ char fl_can_do_alpha_blending() {
RestoreDC(new_gc, save);
DeleteDC(new_gc);
DeleteObject(bm);
ReleaseDC(0L, dc);
if (!fl_gc) ReleaseDC(0L, dc);
if (alpha_ok) can_do = 1;
return can_do;
}
@@ -134,7 +154,7 @@ HDC fl_makeDC(HBITMAP bitmap) {
return new_gc;
}
void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) {
static void fl_copy_offscreen_to_display(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) {
HDC new_gc = CreateCompatibleDC(fl_gc);
int save = SaveDC(new_gc);
SelectObject(new_gc, bitmap);
@@ -149,11 +169,15 @@ void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int src
SelectObject(new_gc, bitmap);
BOOL alpha_ok = 0;
// first try to alpha blend
if (fl_can_do_alpha_blending())
// if to printer, always try alpha_blend
int to_display = Fl_Surface_Device::surface()->type() == Fl_Display_Device::device_type; // true iff display output
if ( (to_display && fl_can_do_alpha_blending()) || Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) {
alpha_ok = fl_alpha_blend(fl_gc, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc);
// if that failed (it shouldn,t), still copy the bitmap over, but now alpha is 1
if (!alpha_ok)
}
// if that failed (it shouldn't), still copy the bitmap over, but now alpha is 1
if (!alpha_ok) {
BitBlt(fl_gc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY);
}
RestoreDC(new_gc, save);
DeleteDC(new_gc);
}
@@ -184,14 +208,24 @@ Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h) {
return (Fl_Offscreen)ctx;
}
void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) {
static void bmProviderRelease (void *src, const void *data, size_t size)
{
CFIndex count = CFGetRetainCount(src);
CFRelease(src);
if(count == 1) free((void*)data);
}
static void fl_copy_offscreen_to_display(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) {
CGContextRef src = (CGContextRef)osrc;
void *data = CGBitmapContextGetData(src);
int sw = CGBitmapContextGetWidth(src);
int sh = CGBitmapContextGetHeight(src);
CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(src);
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
CGDataProviderRef src_bytes = CGDataProviderCreateWithData( 0L, data, sw*sh*4, 0L);
// when output goes to a Quartz printercontext, release of the bitmap must be
// delayed after the end of the print page
CFRetain(src);
CGDataProviderRef src_bytes = CGDataProviderCreateWithData( src, data, sw*sh*4, bmProviderRelease);
CGImageRef img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, alpha,
src_bytes, 0L, false, kCGRenderingIntentDefault);
// fl_push_clip();
@@ -207,17 +241,20 @@ void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int sr
void fl_delete_offscreen(Fl_Offscreen ctx) {
if (!ctx) return;
void *data = CGBitmapContextGetData((CGContextRef)ctx);
CFIndex count = CFGetRetainCount(ctx);
CGContextRelease((CGContextRef)ctx);
if (!data) return;
free(data);
if(count == 1) free(data);
}
const int stack_max = 16;
static int stack_ix = 0;
static CGContextRef stack_gc[stack_max];
static Window stack_window[stack_max];
static Fl_Surface_Device *_ss;
void fl_begin_offscreen(Fl_Offscreen ctx) {
_ss = fl_surface;
fl_display_device->set_current();
if (stack_ix<stack_max) {
stack_gc[stack_ix] = fl_gc;
stack_window[stack_ix] = fl_window;
@@ -227,14 +264,13 @@ void fl_begin_offscreen(Fl_Offscreen ctx) {
fl_gc = (CGContextRef)ctx;
fl_window = 0;
//fl_push_no_clip();
CGContextSaveGState(fl_gc);
Fl_X::q_fill_context();
fl_push_no_clip();
}
void fl_end_offscreen() {
Fl_X::q_release_context();
//fl_pop_clip();
fl_pop_clip();
if (stack_ix>0)
stack_ix--;
else
@@ -243,6 +279,7 @@ void fl_end_offscreen() {
fl_gc = stack_gc[stack_ix];
fl_window = stack_window[stack_ix];
}
_ss->set_current();
}
extern void fl_restore_clip();
@@ -289,7 +326,7 @@ void Fl_Double_Window::flush(int eraseoverlay) {
}
#if USE_XDBE
if (use_xdbe) {
if (myi->backbuffer_bad) {
if (myi->backbuffer_bad || eraseoverlay) {
// Make sure we do a complete redraw...
if (myi->region) {XDestroyRegion(myi->region); myi->region = 0;}
clear_damage(FL_DAMAGE_ALL);
@@ -353,7 +390,15 @@ void Fl_Double_Window::resize(int X,int Y,int W,int H) {
int oh = h();
Fl_Window::resize(X,Y,W,H);
#if USE_XDBE
if (use_xdbe) return;
if (use_xdbe) {
Fl_X* myi = Fl_X::i(this);
if (myi && myi->other_xid && (ow < w() || oh < h())) {
// STR #2152: Deallocate the back buffer to force creation of a new one.
XdbeDeallocateBackBufferName(fl_display,myi->other_xid);
myi->other_xid = 0;
}
return;
}
#endif
Fl_X* myi = Fl_X::i(this);
if (myi && myi->other_xid && (ow != w() || oh != h())) {
@@ -383,5 +428,5 @@ Fl_Double_Window::~Fl_Double_Window() {
}
//
// End of "$Id: Fl_Double_Window.cxx 6616 2009-01-01 21:28:26Z matt $".
// End of "$Id: Fl_Double_Window.cxx 7671 2010-07-09 17:31:33Z manolo $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_File_Browser.cxx 6853 2009-09-09 05:16:41Z greg.ercolano $"
// "$Id: Fl_File_Browser.cxx 7352 2010-03-29 10:47:11Z matt $"
//
// Fl_File_Browser routines.
//
@@ -65,14 +65,11 @@
# include <os2.h>
#endif // __EMX__
// CodeWarrior (__MWERKS__) gets its include paths confused, so we
// temporarily disable this...
#if defined(__APPLE__) && !defined(__MWERKS__)
#if defined(__APPLE__)
# include <sys/param.h>
# include <sys/ucred.h>
# include <sys/mount.h>
#endif // __APPLE__ && !__MWERKS__
#endif // __APPLE__
//
// FL_BLINE definition from "Fl_Browser.cxx"...
@@ -504,7 +501,7 @@ Fl_File_Browser::load(const char *directory,// I - Directory to load
num_files ++;
}
#elif defined(__APPLE__) && !defined(__MWERKS__)
#elif defined(__APPLE__)
// MacOS X and Darwin use getfsstat() system call...
int numfs; // Number of file systems
struct statfs *fs; // Buffer for file system info
@@ -642,5 +639,5 @@ Fl_File_Browser::filter(const char *pattern) // I - Pattern string
//
// End of "$Id: Fl_File_Browser.cxx 6853 2009-09-09 05:16:41Z greg.ercolano $".
// End of "$Id: Fl_File_Browser.cxx 7352 2010-03-29 10:47:11Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_File_Chooser2.cxx 6899 2009-09-23 21:32:23Z matt $"
// "$Id: Fl_File_Chooser2.cxx 7672 2010-07-10 09:44:45Z matt $"
//
// More Fl_File_Chooser routines.
//
@@ -304,6 +304,9 @@
/** \fn void * Fl_File_Chooser::user_data() const
Gets the file chooser user data d */
/** \fn Fl_File_Browser* Fl_File_Chooser::browser()
returns a pointer to the underlying Fl_File_Browser object */
// *** END OF OUT OF SOURCE DOC ***
// Contents:
@@ -858,7 +861,7 @@ Fl_File_Chooser::fileNameCB()
}
} else {
// File doesn't exist, so beep at and alert the user...
fl_alert(existing_file_label);
fl_alert("%s",existing_file_label);
}
}
else if (Fl::event_key() != FL_Delete &&
@@ -1028,6 +1031,8 @@ Fl_File_Chooser::filter(const char *p) // I - Pattern(s)
if (!allfiles) showChoice->add(all_files_label);
showChoice->add(custom_filter_label);
// TODO: add a menu item to switch hidden files on and off
showChoice->value(0);
showChoiceCB();
@@ -1046,7 +1051,7 @@ Fl_File_Chooser::newdir()
// Get a directory name from the user
if ((dir = fl_input(new_directory_label, NULL)) == NULL)
if ((dir = fl_input("%s", NULL, new_directory_label)) == NULL)
return;
// Make it relative to the current directory as needed...
@@ -1213,7 +1218,7 @@ Fl_File_Chooser::showChoiceCB()
item = showChoice->text(showChoice->value());
if (strcmp(item, custom_filter_label) == 0) {
if ((item = fl_input(custom_filter_label, pattern_)) != NULL) {
if ((item = fl_input("%s", pattern_, custom_filter_label)) != NULL) {
strlcpy(pattern_, item, sizeof(pattern_));
quote_pathname(temp, item, sizeof(temp));
@@ -1284,24 +1289,48 @@ void
Fl_File_Chooser::update_preview()
{
const char *filename; // Current filename
Fl_Shared_Image *image, // New image
const char *newlabel = 0; // New label text
Fl_Shared_Image *image = 0, // New image
*oldimage; // Old image
int pbw, pbh; // Width and height of preview box
int w, h; // Width and height of preview image
int set = 0; // Set this flag as soon as a decent preview is found
if (!previewButton->value()) return;
if ((filename = value()) == NULL || fl_filename_isdir(filename)) image = NULL;
else {
window->cursor(FL_CURSOR_WAIT);
Fl::check();
image = Fl_Shared_Image::get(filename);
if (image) {
window->cursor(FL_CURSOR_DEFAULT);
Fl::check();
filename = value();
if (filename == NULL) {
// no file name at all, so we have an empty preview
set = 1;
} else if (fl_filename_isdir(filename)) {
// filename is a directory, show a folder icon
newlabel = "@fileopen";
set = 1;
} else {
struct stat s;
if (fl_stat(filename, &s)==0) {
if ((s.st_mode&S_IFMT)!=S_IFREG) {
// this is no regular file, probably some kind of device
newlabel = "@-3refresh"; // a cross
set = 1;
} else if (s.st_size==0) {
// this file is emty
newlabel = "<empty file>";
set = 1;
} else {
// if this file is an image, try to load it
window->cursor(FL_CURSOR_WAIT);
Fl::check();
image = Fl_Shared_Image::get(filename);
if (image) {
window->cursor(FL_CURSOR_DEFAULT);
Fl::check();
set = 1;
}
}
}
}
@@ -1311,7 +1340,7 @@ Fl_File_Chooser::update_preview()
previewBox->image(0);
if (!image) {
if (!set) {
FILE *fp;
int bytes;
char *ptr;
@@ -1368,7 +1397,7 @@ Fl_File_Chooser::update_preview()
// Non-printable file, just show a big ?...
previewBox->label(filename ? "?" : 0);
previewBox->align(FL_ALIGN_CLIP);
previewBox->labelsize(100);
previewBox->labelsize(75);
previewBox->labelfont(FL_HELVETICA);
} else {
// Show the first 1k of text...
@@ -1382,7 +1411,7 @@ Fl_File_Chooser::update_preview()
previewBox->labelsize(size);
previewBox->labelfont(FL_COURIER);
}
} else {
} else if (image) {
pbw = previewBox->w() - 20;
pbh = previewBox->h() - 20;
@@ -1405,6 +1434,11 @@ Fl_File_Chooser::update_preview()
previewBox->align(FL_ALIGN_CLIP);
previewBox->label(0);
} else if (newlabel) {
previewBox->label(newlabel);
previewBox->align(FL_ALIGN_CLIP);
previewBox->labelsize(newlabel[0]=='@'?75:12);
previewBox->labelfont(FL_HELVETICA);
}
previewBox->redraw();
@@ -1616,5 +1650,5 @@ unquote_pathname(char *dst, // O - Destination string
//
// End of "$Id: Fl_File_Chooser2.cxx 6899 2009-09-23 21:32:23Z matt $".
// End of "$Id: Fl_File_Chooser2.cxx 7672 2010-07-10 09:44:45Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_File_Input.cxx 6758 2009-04-13 07:32:01Z matt $"
// "$Id: Fl_File_Input.cxx 7115 2010-02-20 17:40:07Z AlbrechtS $"
//
// File_Input header file for the Fast Light Tool Kit (FLTK).
//
@@ -215,9 +215,12 @@ Fl_File_Input::handle(int event) // I - Event
return Fl_Input::handle(event);
default :
if (Fl_Input::handle(event)) {
damage(FL_DAMAGE_BAR);
return 1;
{ Fl_Widget_Tracker wp(this);
if (Fl_Input::handle(event)) {
if (wp.exists())
damage(FL_DAMAGE_BAR);
return 1;
}
}
return 0;
}
@@ -290,5 +293,5 @@ Fl_File_Input::handle_button(int event) // I - Event
//
// End of "$Id: Fl_File_Input.cxx 6758 2009-04-13 07:32:01Z matt $".
// End of "$Id: Fl_File_Input.cxx 7115 2010-02-20 17:40:07Z AlbrechtS $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Font.H 6779 2009-04-24 09:28:30Z yuri $"
// "$Id: Fl_Font.H 7351 2010-03-29 10:35:00Z matt $"
//
// Font definitions for the Fast Light Tool Kit (FLTK).
//
@@ -58,15 +58,12 @@ public:
TEXTMETRIC metr;
int angle;
FL_EXPORT Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size);
# elif defined(__APPLE_QD__)
FL_EXPORT Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size);
short font, face, size;
short ascent, descent;
short width[256];
bool knowMetrics;
# elif defined(__APPLE_QUARTZ__)
FL_EXPORT Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size);
ATSUTextLayout layout;
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
CTFontRef fontref;
# endif
ATSUStyle style;
short ascent, descent, q_width;
// short width[256];
@@ -118,5 +115,5 @@ FL_EXPORT char *fl_find_fontsize(char *name);
#endif
//
// End of "$Id: Fl_Font.H 6779 2009-04-24 09:28:30Z yuri $".
// End of "$Id: Fl_Font.H 7351 2010-03-29 10:35:00Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Gl_Choice.H 6616 2009-01-01 21:28:26Z matt $"
// "$Id: Fl_Gl_Choice.H 7564 2010-04-28 07:21:41Z greg.ercolano $"
//
// OpenGL definitions for the Fast Light Tool Kit (FLTK).
//
@@ -20,7 +20,9 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@easysw.com".
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
// Internal interface to set up OpenGL.
@@ -57,10 +59,6 @@
#ifdef WIN32
# include <FL/gl.h>
# define GLContext HGLRC
#elif defined(__APPLE_QD__)
# include <OpenGL/gl.h>
# include <AGL/agl.h>
# define GLContext AGLContext
#elif defined(__APPLE_QUARTZ__)
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
# include <OpenGL/gl.h>
@@ -80,8 +78,6 @@ public:
#ifdef WIN32
int pixelformat; // the visual to use
PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing
#elif defined(__APPLE_QD__)
AGLPixelFormat pixelformat;
#elif defined(__APPLE_QUARTZ__)
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
AGLPixelFormat pixelformat;
@@ -101,10 +97,6 @@ class Fl_Window;
GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
#elif defined(__APPLE_QD__)
GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
#elif defined(__APPLE_QUARTZ__)
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
@@ -128,5 +120,5 @@ void fl_delete_gl_context(GLContext);
#endif
//
// End of "$Id: Fl_Gl_Choice.H 6616 2009-01-01 21:28:26Z matt $".
// End of "$Id: Fl_Gl_Choice.H 7564 2010-04-28 07:21:41Z greg.ercolano $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Group.cxx 6656 2009-02-09 11:41:56Z AlbrechtS $"
// "$Id: Fl_Group.cxx 7469 2010-04-07 23:17:33Z matt $"
//
// Group widget for the Fast Light Tool Kit (FLTK).
//
@@ -77,7 +77,7 @@ void Fl_Group::begin() {current_ = this;}
<I>Exactly the same as</I> current(this->parent()). Any new widgets
added to the widget tree will be added to the parent of the group.
*/
void Fl_Group::end() {current_ = (Fl_Group*)parent();}
void Fl_Group::end() {current_ = parent();}
/**
Returns the currently active group.
@@ -102,7 +102,7 @@ static int send(Fl_Widget* o, int event) {
if (o->type() < FL_WINDOW) return o->handle(event);
switch ( event )
{
case FL_DND_ENTER:
case FL_DND_ENTER: /* FALLTHROUGH */
case FL_DND_DRAG:
// figure out correct type of event:
event = (o->contains(Fl::belowmouse())) ? FL_DND_DRAG : FL_DND_ENTER;
@@ -114,7 +114,7 @@ static int send(Fl_Widget* o, int event) {
Fl::e_x = save_x;
switch ( event )
{
case FL_ENTER:
case FL_ENTER: /* FALLTHROUGH */
case FL_DND_ENTER:
// Successful completion of FL_ENTER means the widget is now the
// belowmouse widget, but only call Fl::belowmouse if the child
@@ -227,8 +227,9 @@ int Fl_Group::handle(int event) {
for (i = children(); i--;) {
o = a[i];
if (o->takesevents() && Fl::event_inside(o)) {
Fl_Widget_Tracker wp(o);
if (send(o,FL_PUSH)) {
if (Fl::pushed() && !o->contains(Fl::pushed())) Fl::pushed(o);
if (Fl::pushed() && wp.exists() && !o->contains(Fl::pushed())) Fl::pushed(o);
return 1;
}
}
@@ -428,7 +429,7 @@ Fl_Group::~Fl_Group() {
*/
void Fl_Group::insert(Fl_Widget &o, int index) {
if (o.parent()) {
Fl_Group* g = (Fl_Group*)(o.parent());
Fl_Group* g = o.parent();
int n = g->find(o);
if (g == this) {
if (index > n) index--;
@@ -744,7 +745,23 @@ void Fl_Group::draw_outside_label(const Fl_Widget& widget) const {
int Y = widget.y();
int W = widget.w();
int H = widget.h();
if (a & FL_ALIGN_TOP) {
if ( (a & 0x0f) == FL_ALIGN_LEFT_TOP ) {
a = (a &~0x0f ) | FL_ALIGN_TOP_RIGHT;
X = x();
W = widget.x()-X-3;
} else if ( (a & 0x0f) == FL_ALIGN_LEFT_BOTTOM ) {
a = (a &~0x0f ) | FL_ALIGN_BOTTOM_RIGHT;
X = x();
W = widget.x()-X-3;
} else if ( (a & 0x0f) == FL_ALIGN_RIGHT_TOP ) {
a = (a &~0x0f ) | FL_ALIGN_TOP_LEFT;
X = X+W+3;
W = x()+this->w()-X;
} else if ( (a & 0x0f) == FL_ALIGN_RIGHT_BOTTOM ) {
a = (a &~0x0f ) | FL_ALIGN_BOTTOM_LEFT;
X = X+W+3;
W = x()+this->w()-X;
} else if (a & FL_ALIGN_TOP) {
a ^= (FL_ALIGN_BOTTOM|FL_ALIGN_TOP);
Y = y();
H = widget.y()-Y;
@@ -765,5 +782,5 @@ void Fl_Group::draw_outside_label(const Fl_Widget& widget) const {
}
//
// End of "$Id: Fl_Group.cxx 6656 2009-02-09 11:41:56Z AlbrechtS $".
// End of "$Id: Fl_Group.cxx 7469 2010-04-07 23:17:33Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Image.cxx 6804 2009-06-29 07:44:25Z AlbrechtS $"
// "$Id: Fl_Image.cxx 7659 2010-07-01 13:21:32Z manolo $"
//
// Image drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -180,19 +180,19 @@ Fl_RGB_Image::~Fl_RGB_Image() {
void Fl_RGB_Image::uncache() {
#ifdef __APPLE_QUARTZ__
if (id) {
CGImageRelease((CGImageRef)id);
id = 0;
if (id_) {
CGImageRelease((CGImageRef)id_);
id_ = 0;
}
#else
if (id) {
fl_delete_offscreen((Fl_Offscreen)id);
id = 0;
if (id_) {
fl_delete_offscreen((Fl_Offscreen)id_);
id_ = 0;
}
if (mask) {
fl_delete_bitmask((Fl_Bitmask)mask);
mask = 0;
if (mask_) {
fl_delete_bitmask((Fl_Bitmask)mask_);
mask_ = 0;
}
#endif
}
@@ -375,7 +375,7 @@ void Fl_RGB_Image::desaturate() {
d(new_d);
}
#if !defined(WIN32) && !USE_QUARTZ
#if !defined(WIN32) && !defined(__APPLE_QUARTZ__)
// Composite an image with alpha on systems that don't have accelerated
// alpha compositing...
static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, int cy) {
@@ -431,115 +431,150 @@ static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, i
delete[] dst;
}
#endif // !WIN32 && !USE_QUARTZ
#endif // !WIN32 && !__APPLE_QUARTZ__
void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
// Don't draw an empty image...
if (!d() || !array) {
draw_empty(XP, YP);
return;
}
fl_graphics_driver->draw(this, XP, YP, WP, HP, cx, cy);
}
static int start(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int w, int h, int &cx, int &cy,
int &X, int &Y, int &W, int &H)
{
// account for current clip region (faster on Irix):
int X,Y,W,H; fl_clip_box(XP,YP,WP,HP,X,Y,W,H);
fl_clip_box(XP,YP,WP,HP,X,Y,W,H);
cx += X-XP; cy += Y-YP;
// clip the box down to the size of image, quit if empty:
if (cx < 0) {W += cx; X -= cx; cx = 0;}
if (cx+W > w()) W = w()-cx;
if (W <= 0) return;
if (cx+W > w) W = w-cx;
if (W <= 0) return 1;
if (cy < 0) {H += cy; Y -= cy; cy = 0;}
if (cy+H > h()) H = h()-cy;
if (H <= 0) return;
if (!id) {
#ifdef __APPLE_QUARTZ__
if (cy+H > h) H = h-cy;
if (H <= 0) return 1;
return 0;
}
#ifdef __APPLE__
void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
// Don't draw an empty image...
if (!img->d() || !img->array) {
img->draw_empty(XP, YP);
return;
}
if (start(img, XP, YP, WP, HP, img->w(), img->h(), cx, cy, X, Y, W, H)) {
return;
}
if (!img->id_) {
CGColorSpaceRef lut = 0;
if (d()<=2)
if (img->d()<=2)
lut = CGColorSpaceCreateDeviceGray();
else
lut = CGColorSpaceCreateDeviceRGB();
CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, w()*h()*d(), 0L);
id = CGImageCreate( w(), h(), 8, d()*8, ld()?ld():w()*d(),
lut, (d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
src, 0L, false, kCGRenderingIntentDefault);
CGDataProviderRef src = CGDataProviderCreateWithData( 0L, img->array, img->w()*img->h()*img->d(), 0L);
img->id_ = CGImageCreate( img->w(), img->h(), 8, img->d()*8, img->ld()?img->ld():img->w()*img->d(),
lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
src, 0L, false, kCGRenderingIntentDefault);
CGColorSpaceRelease(lut);
CGDataProviderRelease(src);
}
if (img->id_ && fl_gc) {
CGRect rect = { { X, Y }, { W, H } };
Fl_X::q_begin_image(rect, cx, cy, img->w(), img->h());
CGContextDrawImage(fl_gc, rect, (CGImageRef)img->id_);
Fl_X::q_end_image();
}
}
#elif defined(WIN32)
id = fl_create_offscreen(w(), h());
if ((d() == 2 || d() == 4) && fl_can_do_alpha_blending()) {
fl_begin_offscreen((Fl_Offscreen)id);
fl_draw_image(array, 0, 0, w(), h(), d()|FL_IMAGE_WITH_ALPHA, ld());
void Fl_GDI_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
// Don't draw an empty image...
if (!img->d() || !img->array) {
img->draw_empty(XP, YP);
return;
}
if (start(img, XP, YP, WP, HP, img->w(), img->h(), cx, cy, X, Y, W, H)) {
return;
}
if (!img->id_) {
img->id_ = fl_create_offscreen(img->w(), img->h());
if ((img->d() == 2 || img->d() == 4) && fl_can_do_alpha_blending()) {
fl_begin_offscreen((Fl_Offscreen)img->id_);
fl_draw_image(img->array, 0, 0, img->w(), img->h(), img->d()|FL_IMAGE_WITH_ALPHA, img->ld());
fl_end_offscreen();
} else {
fl_begin_offscreen((Fl_Offscreen)id);
fl_draw_image(array, 0, 0, w(), h(), d(), ld());
fl_begin_offscreen((Fl_Offscreen)img->id_);
fl_draw_image(img->array, 0, 0, img->w(), img->h(), img->d(), img->ld());
fl_end_offscreen();
if (d() == 2 || d() == 4) {
mask = fl_create_alphamask(w(), h(), d(), ld(), array);
if (img->d() == 2 || img->d() == 4) {
img->mask_ = fl_create_alphamask(img->w(), img->h(), img->d(), img->ld(), img->array);
}
}
}
if (img->mask_) {
HDC new_gc = CreateCompatibleDC(fl_gc);
int save = SaveDC(new_gc);
SelectObject(new_gc, (void*)img->mask_);
BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND);
SelectObject(new_gc, (void*)img->id_);
BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCPAINT);
RestoreDC(new_gc,save);
DeleteDC(new_gc);
} else if (img->d()==2 || img->d()==4) {
fl_copy_offscreen_with_alpha(X, Y, W, H, (Fl_Offscreen)img->id_, cx, cy);
} else {
fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)img->id_, cx, cy);
}
}
#else
if (d() == 1 || d() == 3) {
id = fl_create_offscreen(w(), h());
fl_begin_offscreen((Fl_Offscreen)id);
fl_draw_image(array, 0, 0, w(), h(), d(), ld());
void Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
// Don't draw an empty image...
if (!img->d() || !img->array) {
img->draw_empty(XP, YP);
return;
}
if (start(img, XP, YP, WP, HP, img->w(), img->h(), cx, cy, X, Y, W, H)) {
return;
}
if (!img->id_) {
if (img->d() == 1 || img->d() == 3) {
img->id_ = fl_create_offscreen(img->w(), img->h());
fl_begin_offscreen((Fl_Offscreen)img->id_);
fl_draw_image(img->array, 0, 0, img->w(), img->h(), img->d(), img->ld());
fl_end_offscreen();
}
#endif
}
#if defined(USE_X11)
if (id) {
if (mask) {
if (img->id_) {
if (img->mask_) {
// I can't figure out how to combine a mask with existing region,
// so cut the image down to a clipped rectangle:
int nx, ny; fl_clip_box(X,Y,W,H,nx,ny,W,H);
cx += nx-X; X = nx;
cy += ny-Y; Y = ny;
// make X use the bitmap as a mask:
XSetClipMask(fl_display, fl_gc, mask);
int ox = X-cx; if (ox < 0) ox += w();
int oy = Y-cy; if (oy < 0) oy += h();
XSetClipMask(fl_display, fl_gc, img->mask_);
int ox = X-cx; if (ox < 0) ox += img->w();
int oy = Y-cy; if (oy < 0) oy += img->h();
XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy);
}
fl_copy_offscreen(X, Y, W, H, id, cx, cy);
if (mask) {
fl_copy_offscreen(X, Y, W, H, img->id_, cx, cy);
if (img->mask_) {
// put the old clip region back
XSetClipOrigin(fl_display, fl_gc, 0, 0);
fl_restore_clip();
}
} else {
// Composite image with alpha manually each time...
alpha_blend(this, X, Y, W, H, cx, cy);
alpha_blend(img, X, Y, W, H, cx, cy);
}
#elif defined(WIN32)
if (mask) {
HDC new_gc = CreateCompatibleDC(fl_gc);
int save = SaveDC(new_gc);
SelectObject(new_gc, (void*)mask);
BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND);
SelectObject(new_gc, (void*)id);
BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCPAINT);
RestoreDC(new_gc,save);
DeleteDC(new_gc);
} else if (d()==2 || d()==4) {
fl_copy_offscreen_with_alpha(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
} else {
fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
}
#elif defined(__APPLE_QUARTZ__)
if (id && fl_gc) {
CGRect rect = { { X, Y }, { W, H } };
Fl_X::q_begin_image(rect, cx, cy, w(), h());
CGContextDrawImage(fl_gc, rect, (CGImageRef)id);
Fl_X::q_end_image();
}
#else
# error unsupported platform
#endif
}
#endif
void Fl_RGB_Image::label(Fl_Widget* widget) {
widget->image(this);
}
@@ -551,5 +586,5 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) {
//
// End of "$Id: Fl_Image.cxx 6804 2009-06-29 07:44:25Z AlbrechtS $".
// End of "$Id: Fl_Image.cxx 7659 2010-07-01 13:21:32Z manolo $".
//

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Input_.cxx 6887 2009-09-19 20:57:48Z matt $"
// "$Id: Fl_Input_.cxx 7672 2010-07-10 09:44:45Z matt $"
//
// Common input widget routines for the Fast Light Tool Kit (FLTK).
//
@@ -722,12 +722,12 @@ static void undobuffersize(int n) {
<tt>when() & FL_WHEN_CHANGED</tt> and there is a change.
Set \p b and \p e equal to not delete anything.
Set insert to \c NULL to not insert anything.
Set \p text to \c NULL to not insert anything.
\p ilen must be zero or strlen(insert), this
\p ilen can be zero or <tt>strlen(text)</tt>, which
saves a tiny bit of time if you happen to already know the
length of the insertion, or can be used to insert a portion of a
string or a string containing <tt>nul</tt>'s.
string.
\p b and \p e are clamped to the
<tt>0..size()</tt> range, so it is safe to pass any values.
@@ -1247,12 +1247,12 @@ int Fl_Input_::linesPerPage() {
\param [in] i index into the value field
\return the character at index \p i
*/
Fl_Char Fl_Input_::index(int i) const
unsigned int Fl_Input_::index(int i) const
{
int len = 0;
return fl_utf8decode(value_+i, value_+size_, &len);
}
//
// End of "$Id: Fl_Input_.cxx 6887 2009-09-19 20:57:48Z matt $".
// End of "$Id: Fl_Input_.cxx 7672 2010-07-10 09:44:45Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu.cxx 6841 2009-08-03 06:26:32Z AlbrechtS $"
// "$Id: Fl_Menu.cxx 7151 2010-02-26 13:28:36Z matt $"
//
// Menu code for the Fast Light Tool Kit (FLTK).
//
@@ -330,12 +330,24 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
if (hh+LEADING>itemheight) itemheight = hh+LEADING;
if (m->flags&(FL_SUBMENU|FL_SUBMENU_POINTER)) w1 += 14;
if (w1 > W) W = w1;
// calculate the maximum width of all shortcuts
if (m->shortcut_) {
// s is a pointerto the utf8 string for the entire shortcut
// k points only to the key part (minus the modifier keys)
const char *k, *s = fl_shortcut_label(m->shortcut_, &k);
w1 = int(fl_width(s, k-s));
if (w1 > hotModsw) hotModsw = w1;
w1 = int(fl_width(k))+4;
if (w1 > hotKeysw) hotKeysw = w1;
if (fl_utf_nb_char((const unsigned char*)k, strlen(k))<=4) {
// a regular shortcut has a right-justified modifier followed by a left-justified key
w1 = int(fl_width(s, k-s));
if (w1 > hotModsw) hotModsw = w1;
w1 = int(fl_width(k))+4;
if (w1 > hotKeysw) hotKeysw = w1;
} else {
// a shortcut with a long modifier is right-justified to the menu
w1 = int(fl_width(s))+4;
if (w1 > (hotModsw+hotKeysw)) {
hotModsw = w1-hotKeysw;
}
}
}
if (m->labelcolor_ || Fl::scheme() || m->labeltype_ > FL_NO_LABEL) clear_overlay();
}
@@ -446,9 +458,15 @@ void menuwindow::drawentry(const Fl_Menu_Item* m, int n, int eraseit) {
fl_font(f, m->labelsize_ ? m->labelsize_ :
button ? button->textsize() : FL_NORMAL_SIZE);
const char *k, *s = fl_shortcut_label(m->shortcut_, &k);
char buf[32]; strcpy(buf, s); buf[k-s] = 0;
fl_draw(buf, xx, yy, ww-shortcutWidth, hh, FL_ALIGN_RIGHT);
fl_draw( k, xx+ww-shortcutWidth, yy, shortcutWidth, hh, FL_ALIGN_LEFT);
if (fl_utf_nb_char((const unsigned char*)k, strlen(k))<=4) {
// righ-align the modifiers and left-align the key
char buf[32]; strcpy(buf, s); buf[k-s] = 0;
fl_draw(buf, xx, yy, ww-shortcutWidth, hh, FL_ALIGN_RIGHT);
fl_draw( k, xx+ww-shortcutWidth, yy, shortcutWidth, hh, FL_ALIGN_LEFT);
} else {
// right-align to the menu
fl_draw(s, xx, yy, ww-4, hh, FL_ALIGN_RIGHT);
}
}
if (m->flags & FL_MENU_DIVIDER) {
@@ -1014,5 +1032,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const {
}
//
// End of "$Id: Fl_Menu.cxx 6841 2009-08-03 06:26:32Z AlbrechtS $".
// End of "$Id: Fl_Menu.cxx 7151 2010-02-26 13:28:36Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu_.cxx 6904 2009-09-27 11:39:02Z matt $"
// "$Id: Fl_Menu_.cxx 7517 2010-04-16 17:55:45Z greg.ercolano $"
//
// Common menu code for the Fast Light Tool Kit (FLTK).
//
@@ -39,12 +39,36 @@
#define SAFE_STRCAT(s) { len += strlen(s); if ( len >= namelen ) { *name='\0'; return(-2); } else strcat(name,(s)); }
/** Set 'pathname' of specified menuitem
If finditem==NULL, mvalue() is used (the most recently picked menuitem)
Returns:
- 0 : OK
- -1 : item not found (name="")
- -2 : 'name' not large enough (name="")
/** Get the menu 'pathname' for the specified menuitem.
If finditem==NULL, mvalue() is used (the most recently picked menuitem).
\b Example:
\code
Fl_Menu_Bar *menubar = 0;
void my_menu_callback(Fl_Widget*,void*) {
char name[80];
if ( menubar->item_pathname(name, sizeof(name)-1) == 0 ) { // recently picked item
if ( strcmp(name, "File/&Open") == 0 ) { .. } // open invoked
if ( strcmp(name, "File/&Save") == 0 ) { .. } // save invoked
if ( strcmp(name, "Edit/&Copy") == 0 ) { .. } // copy invoked
}
}
int main() {
[..]
menubar = new Fl_Menu_Bar(..);
menubar->add("File/&Open", 0, my_menu_callback);
menubar->add("File/&Save", 0, my_menu_callback);
menubar->add("Edit/&Copy", 0, my_menu_callback);
[..]
}
\endcode
\returns
- 0 : OK (name has menuitem's pathname)
- -1 : item not found (name="")
- -2 : 'name' not large enough (name="")
\see find_item()
*/
int Fl_Menu_::item_pathname(char *name, int namelen, const Fl_Menu_Item *finditem) const {
int len = 0;
@@ -55,6 +79,7 @@ int Fl_Menu_::item_pathname(char *name, int namelen, const Fl_Menu_Item *findite
if ( m->submenu() ) { // submenu? descend
if (*name) SAFE_STRCAT("/");
if (m->label()) SAFE_STRCAT(m->label());
if ( m == finditem ) return(0); // found? done.
} else {
if (m->label()) { // menu item?
if ( m == finditem ) { // found? tack on itemname, done.
@@ -75,23 +100,106 @@ int Fl_Menu_::item_pathname(char *name, int namelen, const Fl_Menu_Item *findite
}
/**
Find menu item index, given menu pathname
eg. "Edit/Copy"
Will also return submenus, eg. "Edit"
Returns NULL if not found.
*/
const Fl_Menu_Item * Fl_Menu_::find_item(const char *name) {
char menupath[1024] = ""; // File/Export
Find the menu item for a given menu \p pathname, such as "Edit/Copy".
This method finds a menu item in the menu array, also traversing submenus, but
not submenu pointers.
To get the menu item's index, use find_index(const char*)
\b Example:
\code
Fl_Menu_Bar *menubar = new Fl_Menu_Bar(..);
menubar->add("File/&Open");
menubar->add("File/&Save");
menubar->add("Edit/&Copy");
// [..]
Fl_Menu_Item *item;
if ( ( item = (Fl_Menu_Item*)menubar->find_item("File/&Open") ) != NULL ) {
item->labelcolor(FL_RED);
}
if ( ( item = (Fl_Menu_Item*)menubar->find_item("Edit/&Copy") ) != NULL ) {
item->labelcolor(FL_GREEN);
}
\endcode
\param pathname The path and name of the menu item
\returns The item found, or NULL if not found
\see find_index(const char*), find_item(Fl_Callback*), item_pathname()
*/
const Fl_Menu_Item * Fl_Menu_::find_item(const char *pathname) {
int i = find_index(pathname);
return( (i==-1) ? 0 : (const Fl_Menu_Item*)(menu_+i));
}
/**
Find the index the menu array for given \p item.
A way to convert a menu item pointer into an index.
Current implementation is fast and not expensive.
\code
// Convert an index-to-item
int index = 12;
const Fl_Menu_Item *item = mymenu->menu() + index;
// Convert an item-to-index
int index = mymenu->find_index(item);
if ( index == -1 ) { ..error.. }
\endcode
\param item The *item to be found
\returns The index of the item, or -1 if not found.
\see menu()
*/
int Fl_Menu_::find_index(const Fl_Menu_Item *item) const {
Fl_Menu_Item *max = menu_+size();
if (item<menu_ || item>=max) return(-1);
return(item-menu_);
}
/**
Find the index into the menu array for a given callback \p cb.
This method finds a menu item's index position, also traversing submenus, but
not submenu pointers. This is useful if an application uses internationalisation
and a menu item can not be found using its label. This search is also much faster.
\param cb Find the first item with this callback
\returns The index of the item with the specific callback, or -1 if not found
\see find_index(const char*)
*/
int Fl_Menu_::find_index(Fl_Callback *cb) const {
for ( int t=0; t < size(); t++ )
if (menu_[t].callback_==cb)
return(t);
return(-1);
}
/**
Find the menu item index for a given menu \p pathname, such as "Edit/Copy".
This method finds a menu item's index position for the given menu pathname,
also traversing submenus, but not submenu pointers.
To get the menu item pointer for a pathname, use find_item()
\param pathname The path and name of the menu item index to find
\returns The index of the matching item, or -1 if not found.
\see item_pathname()
*/
int Fl_Menu_::find_index(const char *pathname) const {
char menupath[1024] = ""; // File/Export
for ( int t=0; t < size(); t++ ) {
Fl_Menu_Item *m = menu_ + t;
if (m->flags&FL_SUBMENU) {
// IT'S A SUBMENU
// we do not support searches through FL_SUBMENU_POINTER links
if (menupath[0]) strlcat(menupath, "/", sizeof(menupath));
strlcat(menupath, m->label(), sizeof(menupath));
if (!strcmp(menupath, name)) return m;
if (!strcmp(menupath, pathname)) return(t);
} else {
if (!m->label()) {
// END OF SUBMENU? Pop back one level.
@@ -100,16 +208,36 @@ const Fl_Menu_Item * Fl_Menu_::find_item(const char *name) {
else menupath[0] = '\0';
continue;
}
// IT'S A MENU ITEM
char itempath[1024]; // eg. Edit/Copy
strcpy(itempath, menupath);
if (itempath[0]) strlcat(itempath, "/", sizeof(itempath));
strlcat(itempath, m->label(), sizeof(itempath));
if (!strcmp(itempath, name)) return m;
if (!strcmp(itempath, pathname)) return(t);
}
}
return(-1);
}
/**
Find the menu item for the given callback \p cb.
This method finds a menu item in a menu array, also traversing submenus, but
not submenu pointers. This is useful if an application uses
internationalisation and a menu item can not be found using its label. This
search is also much faster.
\param cb find the first item with this callback
\returns The item found, or NULL if not found
\see find_item(const char*)
*/
const Fl_Menu_Item * Fl_Menu_::find_item(Fl_Callback *cb) {
for ( int t=0; t < size(); t++ ) {
const Fl_Menu_Item *m = menu_ + t;
if (m->callback_==cb) {
return m;
}
}
return (const Fl_Menu_Item *)0;
}
@@ -206,7 +334,7 @@ int Fl_Menu_::size() const {
Sets the menu array pointer directly. If the old menu is private it is
deleted. NULL is allowed and acts the same as a zero-length
menu. If you try to modify the array (with add(), replace(), or
delete()) a private copy is automatically done.
remove()) a private copy is automatically done.
*/
void Fl_Menu_::menu(const Fl_Menu_Item* m) {
clear();
@@ -217,7 +345,7 @@ void Fl_Menu_::menu(const Fl_Menu_Item* m) {
/**
Sets the menu array pointer with a copy of m that will be automatically deleted.
If ud is not NULL, then all user data pointers are changed in the menus as well.
If userdata \p ud is not NULL, then all user data pointers are changed in the menus as well.
See void Fl_Menu_::menu(const Fl_Menu_Item* m).
*/
void Fl_Menu_::copy(const Fl_Menu_Item* m, void* ud) {
@@ -261,6 +389,47 @@ void Fl_Menu_::clear() {
}
}
/**
Clears the specified submenu pointed to by \p index of all menu items.
This method is useful for clearing a submenu so that it can be
re-populated with new items. Example: a "File/Recent Files/..." submenu
that shows the last few files that have been opened.
The specified \p index must point to a submenu.
The submenu is cleared with remove().
If the menu array was directly set with menu(x), then copy()
is done to make a private array.
\warning Since this method can change the internal menu array, any menu
item pointers or indecies the application may have cached can become
stale, and should be recalculated/refreshed.
\b Example:
\code
int index = menubar->find_index("File/Recent"); // get index of "File/Recent" submenu
if ( index != -1 ) menubar->clear_submenu(index); // clear the submenu
menubar->add("File/Recent/Aaa");
menubar->add("File/Recent/Bbb");
[..]
\endcode
\param index The index of the submenu to be cleared
\returns 0 on success, -1 if the index is out of range or not a submenu
\see remove(int)
*/
int Fl_Menu_::clear_submenu(int index) {
if ( index < 0 || index >= size() ) return(-1);
if ( ! (menu_[index].flags & FL_SUBMENU) ) return(-1);
++index; // advance to first item in submenu
while ( index < size() ) { // keep remove()ing top item until end is reached
if ( menu_[index].text == 0 ) break; // end of this submenu? done
remove(index); // remove items/submenus
}
return(0);
}
//
// End of "$Id: Fl_Menu_.cxx 6904 2009-09-27 11:39:02Z matt $".
// End of "$Id: Fl_Menu_.cxx 7517 2010-04-16 17:55:45Z greg.ercolano $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu_Button.cxx 6659 2009-02-15 13:49:34Z AlbrechtS $"
// "$Id: Fl_Menu_Button.cxx 7162 2010-02-26 21:10:46Z matt $"
//
// Menu button widget for the Fast Light Tool Kit (FLTK).
//
@@ -73,7 +73,7 @@ const Fl_Menu_Item* Fl_Menu_Button::popup() {
int Fl_Menu_Button::handle(int e) {
if (!menu() || !menu()->text) return 0;
switch (e) {
case FL_ENTER:
case FL_ENTER: /* FALLTHROUGH */
case FL_LEAVE:
return (box() && !type()) ? 1 : 0;
case FL_PUSH:
@@ -95,7 +95,7 @@ int Fl_Menu_Button::handle(int e) {
case FL_SHORTCUT:
if (Fl_Widget::test_shortcut()) {popup(); return 1;}
return test_shortcut() != 0;
case FL_FOCUS:
case FL_FOCUS: /* FALLTHROUGH */
case FL_UNFOCUS:
if (box() && Fl::visible_focus()) {
redraw();
@@ -118,5 +118,5 @@ Fl_Menu_Button::Fl_Menu_Button(int X,int Y,int W,int H,const char *l)
}
//
// End of "$Id: Fl_Menu_Button.cxx 6659 2009-02-15 13:49:34Z AlbrechtS $".
// End of "$Id: Fl_Menu_Button.cxx 7162 2010-02-26 21:10:46Z matt $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu_add.cxx 6878 2009-09-17 22:12:24Z matt $"
// "$Id: Fl_Menu_add.cxx 7519 2010-04-16 19:50:40Z greg.ercolano $"
//
// Menu utilities for the Fast Light Tool Kit (FLTK).
//
@@ -53,11 +53,12 @@ extern Fl_Menu_* fl_menu_array_owner; // in Fl_Menu_.cxx
// Insert a single Fl_Menu_Item into an array of size at offset n,
// if this is local_array it will be reallocated if needed.
static Fl_Menu_Item* insert(
Fl_Menu_Item* array, int size,
int n,
const char *text,
int flags
static Fl_Menu_Item* array_insert(
Fl_Menu_Item* array, // array to modify
int size, // size of array
int n, // index of new insert position
const char *text, // text of new item (copy is made)
int flags // flags for new item
) {
if (array == local_array && size >= local_array_alloc) {
local_array_alloc = 2*size;
@@ -106,6 +107,27 @@ int Fl_Menu_Item::add(
Fl_Callback *cb,
void *data,
int myflags
) {
return(insert(-1,mytext,sc,cb,data,myflags)); // -1: append
}
/** Inserts an item at position \p index.
If \p index is -1, the item is added the same way as Fl_Menu_Item::add().
If 'mytext' contains any un-escaped front slashes (/), it's assumed
a menu pathname is being specified, and the value of \p index
will be ignored.
In all other aspects, the behavior of insert() is the same as add().
*/
int Fl_Menu_Item::insert(
int index,
const char *mytext,
int sc,
Fl_Callback *cb,
void *data,
int myflags
) {
Fl_Menu_Item *array = this;
Fl_Menu_Item *m = this;
@@ -133,17 +155,18 @@ int Fl_Menu_Item::add(
item = buf;
if (*p != '/') break; /* not a menu title */
mytext = p+1; /* point at item title */
index = -1; /* any submenu specified overrides insert position */
mytext = p+1; /* point at item title */
/* find a matching menu title: */
for (; m->text; m = m->next())
if (m->flags&FL_SUBMENU && !compare(item, m->text)) break;
if (!m->text) { /* create a new menu */
int n = m-array;
array = insert(array, msize, n, item, FL_SUBMENU|flags1);
int n = (index==-1) ? m-array : index;
array = array_insert(array, msize, n, item, FL_SUBMENU|flags1);
msize++;
array = insert(array, msize, n+1, 0, 0);
array = array_insert(array, msize, n+1, 0, 0);
msize++;
m = array+n;
}
@@ -156,11 +179,11 @@ int Fl_Menu_Item::add(
if (!(m->flags&FL_SUBMENU) && !compare(m->text,item)) break;
if (!m->text) { /* add a new menu item */
int n = m-array;
array = insert(array, msize, n, item, myflags|flags1);
int n = (index==-1) ? m-array : index;
array = array_insert(array, msize, n, item, myflags|flags1);
msize++;
if (myflags & FL_SUBMENU) { // add submenu delimiter
array = insert(array, msize, n+1, 0, 0);
array = array_insert(array, msize, n+1, 0, 0);
msize++;
}
m = array+n;
@@ -179,17 +202,21 @@ int Fl_Menu_Item::add(
/**
Adds a new menu item.
\param[in] label The text label for the menu item.
\param[in] label The text label for the menu item.
\param[in] shortcut Optional keyboard shortcut that can be an int or string; (FL_CTRL+'a') or "^a". Default 0 if none.
\param[in] callback Optional callback invoked when user clicks the item. Default 0 if none.
\param[in] userdata Optional user data passed as an argument to the callback. Default 0 if none.
\param[in] flags Optional flags that control the type of menu item; see below. Default is 0 for none.
\returns The index into the menu() array, where the entry was added.
\param[in] flags Optional flags that control the type of menu item; see below. Default is 0 for none.
\returns The index into the menu() array, where the entry was added.
\par Description
If the menu array was directly set with menu(x), then copy() is done
to make a private array.
\par
Since this method can change the internal menu array, any menu item
pointers or indecies the application may have cached can become stale,
and should be recalculated/refreshed.
\par
A menu item's callback must not add() items to its parent menu during the callback.
<B>Detailed Description of Parameters</B>
@@ -219,23 +246,32 @@ int Fl_Menu_Item::add(
\par
This parameter is optional, and defaults to 0 to indicate no shortcut.
\par
Shortcut can be 0L, or either a modifier/key combination (for example
FL_CTRL+'A') or a string describing the shortcut in one of two ways:
The shortcut can either be a raw integer value (eg. FL_CTRL+'A')
or a string (eg. "^c" or "^97").
\par
Raw integer shortcuts can be a combination of keyboard chars (eg. 'A')
and optional keyboard modifiers (see Fl::event_state(), e.g. FL_SHIFT, etc).
\par
String shortcuts can be specified in one of two ways:
\par
\verbatim
[#+^]<ascii_value> e.g. "97", "^97", "+97", "#97"
[#+^]<ascii_char> e.g. "a", "^a", "+a", "#a"
\endverbatim
\par
..where \<ascii_value\> is a decimal value representing an
ascii character (eg. 97 is the ascii for 'a'), and the optional
ascii character (eg. 97 is the ascii code for 'a'), and the optional
prefixes enhance the value that follows. Multiple prefixes must
appear in the above order.
\par
\verbatim
# - Alt
+ - Shift
^ - Control
\endverbatim
Text shortcuts are converted to integer shortcut by calling
Fl_Shortcut fl_old_shortcut(const char*).
\par
Internally, the text shortcuts are converted to integer values using
fl_old_shortcut(const char*).
\par callback
The callback to invoke when this menu item is selected.
@@ -264,8 +300,52 @@ int Fl_Menu_Item::add(
FL_MENU_DIVIDER // Creates divider line below this item. Also ends a group of radio buttons.
\endcode
\todo Raw integer shortcut needs examples.
Dependent on responses to http://fltk.org/newsgroups.php?gfltk.development+v:10086 and results of STR#2344
*/
int Fl_Menu_::add(const char *label,int shortcut,Fl_Callback *callback,void *userdata,int flags) {
return(insert(-1,label,shortcut,callback,userdata,flags)); // -1: append
}
/**
Inserts a new menu item at the specified \p index position.
If \p index is -1, the menu item is appended; same behavior as add().
To properly insert a menu item, \p label must be the name of the item (eg. "Quit"),
and not a 'menu pathname' (eg. "File/Quit"). If a menu pathname is specified,
the value of \p index is \em ignored, the new item's position defined by the pathname.
For more details, see add(). Except for the \p index parameter, add()
has more detailed information on parameters and behavior, and is
functionally equivalent.
\param[in] index The menu array's index position where the new item
is inserted. If -1, behavior is the same as add().
\param[in] label The text label for the menu item. If the label
is a menu pathname, \p index is ignored, and the pathname
indicates the position of the new item.
\param[in] shortcut Optional keyboard shortcut. Can be an int (FL_CTRL+'a')
or a string ("^a"). Default is 0.
\param[in] callback Optional callback invoked when user clicks the item.
Default 0 if none.
\param[in] userdata Optional user data passed as an argument to the callback.
Default 0 if none.
\param[in] flags Optional flags that control the type of menu item;
see add() for more info. Default is 0 for none.
\returns The index into the menu() array, where the entry was added.
\see add()
*/
int Fl_Menu_::insert(
int index,
const char *label,
int shortcut,
Fl_Callback *callback,
void *userdata,
int flags
) {
// make this widget own the local array:
if (this != fl_menu_array_owner) {
if (fl_menu_array_owner) {
@@ -299,7 +379,7 @@ int Fl_Menu_::add(const char *label,int shortcut,Fl_Callback *callback,void *use
}
fl_menu_array_owner = this;
}
int r = menu_->add(label,shortcut,callback,userdata,flags);
int r = menu_->insert(index,label,shortcut,callback,userdata,flags);
// if it rellocated array we must fix the pointer:
int value_offset = value_-menu_;
menu_ = local_array; // in case it reallocated it
@@ -374,5 +454,5 @@ void Fl_Menu_::remove(int i) {
}
//
// End of "$Id: Fl_Menu_add.cxx 6878 2009-09-17 22:12:24Z matt $".
// End of "$Id: Fl_Menu_add.cxx 7519 2010-04-16 19:50:40Z greg.ercolano $".
//

View File

@@ -0,0 +1,45 @@
// "$Id: Fl_Native_File_Chooser.cxx 7003 2010-01-14 20:47:59Z greg.ercolano $"
//
// FLTK native OS file chooser widget
//
// Copyright 1998-2005 by Bill Spitzak and others.
// Copyright 2004 Greg Ercolano.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to:
//
// http://www.fltk.org/str.php
//
// Use Windows' chooser
#ifdef WIN32
#include "Fl_Native_File_Chooser_WIN32.cxx"
#endif
// Use Apple's chooser
#ifdef __APPLE__
#include "Fl_Native_File_Chooser_MAC.cxx"
#endif
// All else falls back to FLTK's own chooser
#if ! defined(__APPLE__) && !defined(WIN32)
#include "Fl_Native_File_Chooser_FLTK.cxx"
#endif
//
// End of "$Id: Fl_Native_File_Chooser.cxx 7003 2010-01-14 20:47:59Z greg.ercolano $".
//

View File

@@ -0,0 +1,504 @@
// "$Id: Fl_Native_File_Chooser_FLTK.cxx 7015 2010-01-17 17:09:00Z greg.ercolano $"
//
// FLTK native OS file chooser widget
//
// Copyright 1998-2005 by Bill Spitzak and others.
// Copyright 2004 Greg Ercolano.
// API changes + filter improvements by Nathan Vander Wilt 2005
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to:
//
// http://www.fltk.org/str.php
//
#include <FL/Fl_Native_File_Chooser.H>
#include <FL/Fl_File_Icon.H>
#define FLTK_CHOOSER_SINGLE Fl_File_Chooser::SINGLE
#define FLTK_CHOOSER_DIRECTORY Fl_File_Chooser::DIRECTORY
#define FLTK_CHOOSER_MULTI Fl_File_Chooser::MULTI
#define FLTK_CHOOSER_CREATE Fl_File_Chooser::CREATE
#include "Fl_Native_File_Chooser_common.cxx"
#include <sys/stat.h>
#include <string.h>
/**
The constructor. Internally allocates the native widgets.
Optional \p val presets the type of browser this will be,
which can also be changed with type().
*/
Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
//// CANT USE THIS -- MESSES UP LINKING/CREATES DEPENDENCY ON fltk_images.
//// Have app call this from main() instead.
////
//// static int init = 0; // 'first time' initialize flag
//// if ( init == 0 ) {
//// // Initialize when instanced for first time
//// Fl_File_Icon::load_system_icons();
//// init = 1;
//// }
_btype = val;
_options = NO_OPTIONS;
_filter = NULL;
_filtvalue = 0;
_parsedfilt = NULL;
_preset_file = NULL;
_prevvalue = NULL;
_directory = NULL;
_errmsg = NULL;
_file_chooser = new Fl_File_Chooser(NULL, NULL, 0, NULL);
type(val); // do this after _file_chooser created
_nfilters = 0;
// Added by MG
Fl_Button *b = _file_chooser->previewButton;
Fl_Window *w = b->window();
Fl_Group::current(w); // adds a "Show hidden files" check button in _file_chooser's window
show_hidden = new Fl_Check_Button(b->x() + b->w() + 10, b->y(), 145, b->h(), "Show hidden files");
show_hidden->callback((Fl_Callback*)show_hidden_cb, this);
my_fileList = _file_chooser->browser();
_old_dir = 0; // to detect directory changes
prev_filtervalue = _file_chooser->filter_value(); // to detect filter changes
}
/**
Destructor.
Deallocates any resources allocated to this widget.
*/
Fl_Native_File_Chooser::~Fl_Native_File_Chooser() {
delete _file_chooser;
_filter = strfree(_filter);
_parsedfilt = strfree(_parsedfilt);
_preset_file = strfree(_preset_file);
_prevvalue = strfree(_prevvalue);
_directory = strfree(_directory);
_errmsg = strfree(_errmsg);
_old_dir = strfree(_old_dir);
}
// PRIVATE: SET ERROR MESSAGE
void Fl_Native_File_Chooser::errmsg(const char *msg) {
_errmsg = strfree(_errmsg);
_errmsg = strnew(msg);
}
// PRIVATE: translate Native types to Fl_File_Chooser types
int Fl_Native_File_Chooser::type_fl_file(int val) {
switch (val) {
case BROWSE_FILE:
return(FLTK_CHOOSER_SINGLE);
case BROWSE_DIRECTORY:
return(FLTK_CHOOSER_SINGLE | FLTK_CHOOSER_DIRECTORY);
case BROWSE_MULTI_FILE:
return(FLTK_CHOOSER_MULTI);
case BROWSE_MULTI_DIRECTORY:
return(FLTK_CHOOSER_DIRECTORY | FLTK_CHOOSER_MULTI);
case BROWSE_SAVE_FILE:
return(FLTK_CHOOSER_SINGLE | FLTK_CHOOSER_CREATE);
case BROWSE_SAVE_DIRECTORY:
return(FLTK_CHOOSER_DIRECTORY | FLTK_CHOOSER_MULTI | FLTK_CHOOSER_CREATE);
default:
return(FLTK_CHOOSER_SINGLE);
}
}
/**
Sets the current Fl_Native_File_Chooser::Type of browser.
*/
void Fl_Native_File_Chooser::type(int val) {
_btype = val;
_file_chooser->type(type_fl_file(val));
}
/**
Gets the current Fl_Native_File_Chooser::Type of browser.
*/
int Fl_Native_File_Chooser::type() const {
return(_btype);
}
/**
Sets the platform specific chooser options to \p val.
\p val is expected to be one or more Fl_Native_File_Chooser::Option flags ORed together.
Some platforms have OS-specific functions that can be enabled/disabled via this method.
<P>
\code
Flag Description Win Mac Other
-------------- ----------------------------------------------- ------- ------- -------
NEW_FOLDER Shows the 'New Folder' button. Ignored Used Used
PREVIEW Enables the 'Preview' mode by default. Ignored Ignored Used
SAVEAS_CONFIRM Confirm dialog if BROWSE_SAVE_FILE file exists. Ignored Used Used
\endcode
*/
void Fl_Native_File_Chooser::options(int val) {
_options = val;
}
/**
Gets the platform specific Fl_Native_File_Chooser::Option flags.
*/
int Fl_Native_File_Chooser::options() const {
return(_options);
}
/**
Post the chooser's dialog. Blocks until dialog has been completed or cancelled.
\returns
- 0 -- user picked a file
- 1 -- user cancelled
- -1 -- failed; errmsg() has reason
*/
int Fl_Native_File_Chooser::show() {
// FILTER
if ( _parsedfilt ) {
_file_chooser->filter(_parsedfilt);
}
// FILTER VALUE
// Set this /after/ setting the filter
//
_file_chooser->filter_value(_filtvalue);
// DIRECTORY
if ( _directory && _directory[0] ) {
_file_chooser->directory(_directory);
} else {
_file_chooser->directory(_prevvalue);
}
// PRESET FILE
if ( _preset_file ) {
_file_chooser->value(_preset_file);
}
// OPTIONS: PREVIEW
_file_chooser->preview( (options() & PREVIEW) ? 1 : 0);
// OPTIONS: NEW FOLDER
if ( options() & NEW_FOLDER )
_file_chooser->type(_file_chooser->type() | FLTK_CHOOSER_CREATE); // on
// SHOW
_file_chooser->show();
// BLOCK WHILE BROWSER SHOWN
while ( _file_chooser->shown() ) {
if (_old_dir==0 || strcmp(_old_dir, _file_chooser->directory()) != 0) {
_old_dir = strfree(_old_dir);
_old_dir = strnew(_file_chooser->directory());
if (!show_hidden->value()) remove_hidden_files(my_fileList);
} else if (prev_filtervalue != _file_chooser->filter_value() ) {
prev_filtervalue = _file_chooser->filter_value();
if (!show_hidden->value() ) remove_hidden_files(my_fileList);
}
Fl::wait();
}
if ( _file_chooser->value() && _file_chooser->value()[0] ) {
_prevvalue = strfree(_prevvalue);
_prevvalue = strnew(_file_chooser->value());
_filtvalue = _file_chooser->filter_value(); // update filter value
// HANDLE SHOWING 'SaveAs' CONFIRM
if ( options() & SAVEAS_CONFIRM && type() == BROWSE_SAVE_FILE ) {
struct stat buf;
if ( stat(_file_chooser->value(), &buf) != -1 ) {
if ( buf.st_mode & S_IFREG ) { // Regular file + exists?
if ( exist_dialog() == 0 ) {
return(1);
}
}
}
}
}
if ( _file_chooser->count() ) return(0);
else return(1);
}
/**
Returns a system dependent error message for the last method that failed.
This message should at least be flagged to the user in a dialog box, or to some kind of error log.
Contents will be valid only for methods that document errmsg() will have info on failures.
*/
const char *Fl_Native_File_Chooser::errmsg() const {
return(_errmsg ? _errmsg : "No error");
}
/**
Return the filename the user choose.
Use this if only expecting a single filename.
If more than one filename is expected, use filename(int) instead.
Return value may be "" if no filename was chosen (eg. user cancelled).
*/
const char* Fl_Native_File_Chooser::filename() const {
if ( _file_chooser->count() > 0 ) return(_file_chooser->value());
return("");
}
/**
Return one of the filenames the user selected.
Use count() to determine how many filenames the user selected.
<P>
\b Example:
\code
if ( fnfc->show() == 0 ) {
// Print all filenames user selected
for (int n=0; n<fnfc->count(); n++ ) {
printf("%d) '%s'\n", n, fnfc->filename(n));
}
}
\endcode
*/
const char* Fl_Native_File_Chooser::filename(int i) const {
if ( i < _file_chooser->count() )
return(_file_chooser->value(i+1)); // convert fltk 1 based to our 0 based
return("");
}
/**
Set the title of the file chooser's dialog window.
Can be NULL if no title desired.
The default title varies according to the platform, so you are advised to set the title explicitly.
*/
void Fl_Native_File_Chooser::title(const char *val) {
_file_chooser->label(val);
}
/**
Get the title of the file chooser's dialog window.
Return value may be NULL if no title was set.
*/
const char *Fl_Native_File_Chooser::title() const {
return(_file_chooser->label());
}
/**
Sets the filename filters used for browsing.
The default is NULL, which browses all files.
<P>
The filter string can be any of:
<P>
- A single wildcard (eg. "*.txt")
- Multiple wildcards (eg. "*.{cxx,h,H}")
- A descriptive name followed by a "\t" and a wildcard (eg. "Text Files\t*.txt")
- A list of separate wildcards with a "\n" between each (eg. "*.{cxx,H}\n*.txt")
- A list of descriptive names and wildcards (eg. "C++ Files\t*.{cxx,H}\nTxt Files\t*.txt")
<P>
The format of each filter is a wildcard, or an optional user description
followed by '\\t' and the wildcard.
<P>
On most platforms, each filter is available to the user via a pulldown menu
in the file chooser. The 'All Files' option is always available to the user.
*/
void Fl_Native_File_Chooser::filter(const char *val) {
_filter = strfree(_filter);
_filter = strnew(val);
parse_filter();
}
/**
Returns the filter string last set.
Can be NULL if no filter was set.
*/
const char *Fl_Native_File_Chooser::filter() const {
return(_filter);
}
/**
Gets how many filters were available, not including "All Files"
*/
int Fl_Native_File_Chooser::filters() const {
return(_nfilters);
}
/**
Sets which filter will be initially selected.
The first filter is indexed as 0.
If filter_value()==filters(), then "All Files" was chosen.
If filter_value() > filters(), then a custom filter was set.
*/
void Fl_Native_File_Chooser::filter_value(int val) {
_filtvalue = val;
}
/**
Returns which filter value was last selected by the user.
This is only valid if the chooser returns success.
*/
int Fl_Native_File_Chooser::filter_value() const {
return(_filtvalue);
}
/**
Returns the number of filenames (or directory names) the user selected.
<P>
\b Example:
\code
if ( fnfc->show() == 0 ) {
// Print all filenames user selected
for (int n=0; n<fnfc->count(); n++ ) {
printf("%d) '%s'\n", n, fnfc->filename(n));
}
}
\endcode
*/
int Fl_Native_File_Chooser::count() const {
return(_file_chooser->count());
}
/**
Preset the directory the browser will show when opened.
If \p val is NULL, or no directory is specified, the chooser will attempt
to use the last non-cancelled folder.
*/
void Fl_Native_File_Chooser::directory(const char *val) {
_directory = strfree(_directory);
_directory = strnew(val);
}
/**
Returns the current preset directory() value.
*/
const char *Fl_Native_File_Chooser::directory() const {
return(_directory);
}
// PRIVATE: Convert our filter format to fltk's chooser format
// FROM TO (FLTK)
// ------------------------- --------------------------
// "*.cxx" "*.cxx Files(*.cxx)"
// "C Files\t*.{cxx,h}" "C Files(*.{cxx,h})"
// "C Files\t*.{cxx,h}\nText Files\t*.txt" "C Files(*.{cxx,h})\tText Files(*.txt)"
//
// Returns a modified version of the filter that the caller is responsible
// for freeing with strfree().
//
void Fl_Native_File_Chooser::parse_filter() {
_parsedfilt = strfree(_parsedfilt); // clear previous parsed filter (if any)
_nfilters = 0;
char *in = _filter;
if ( !in ) return;
int has_name = strchr(in, '\t') ? 1 : 0;
char mode = has_name ? 'n' : 'w'; // parse mode: n=title, w=wildcard
char wildcard[1024] = ""; // parsed wildcard
char name[1024] = "";
// Parse filter user specified
for ( ; 1; in++ ) {
/*** DEBUG
printf("WORKING ON '%c': mode=<%c> name=<%s> wildcard=<%s>\n",
*in, mode, name, wildcard);
***/
switch (*in) {
// FINISHED PARSING NAME?
case '\t':
if ( mode != 'n' ) goto regchar;
mode = 'w';
break;
// ESCAPE NEXT CHAR
case '\\':
++in;
goto regchar;
// FINISHED PARSING ONE OF POSSIBLY SEVERAL FILTERS?
case '\r':
case '\n':
case '\0':
// APPEND NEW FILTER TO LIST
if ( wildcard[0] ) {
// OUT: "name(wild)\tname(wild)"
char comp[2048];
sprintf(comp, "%s%.511s(%.511s)", ((_parsedfilt)?"\t":""),
name, wildcard);
_parsedfilt = strapp(_parsedfilt, comp);
_nfilters++;
//DEBUG printf("DEBUG: PARSED FILT NOW <%s>\n", _parsedfilt);
}
// RESET
wildcard[0] = name[0] = '\0';
mode = strchr(in, '\t') ? 'n' : 'w';
// DONE?
if ( *in == '\0' ) return; // done
else continue; // not done yet, more filters
// Parse all other chars
default: // handle all non-special chars
regchar: // handle regular char
switch ( mode ) {
case 'n': chrcat(name, *in); continue;
case 'w': chrcat(wildcard, *in); continue;
}
break;
}
}
//NOTREACHED
}
/**
Sets the default filename for the chooser.
Use directory() to set the default directory.
Mainly used to preset the filename for save dialogs,
and on most platforms can be used for opening files as well.
*/
void Fl_Native_File_Chooser::preset_file(const char* val) {
_preset_file = strfree(_preset_file);
_preset_file = strnew(val);
}
/**
Get the preset filename.
*/
const char* Fl_Native_File_Chooser::preset_file() const {
return(_preset_file);
}
void Fl_Native_File_Chooser::show_hidden_cb(Fl_Check_Button *o, void *data)
{
Fl_Native_File_Chooser *mychooser = (Fl_Native_File_Chooser *)data;
if (o->value()) {
mychooser->my_fileList->load(mychooser->_file_chooser->directory());
} else {
remove_hidden_files(mychooser->my_fileList);
mychooser->my_fileList->redraw();
}
}
// PRIVATE: Don't show hidden files
void Fl_Native_File_Chooser::remove_hidden_files(Fl_File_Browser *my_fileList)
{
int count = my_fileList->size();
for(int num = count; num >= 1; num--) {
const char *p = my_fileList->text(num);
if (*p == '.' && strcmp(p, "../") != 0) my_fileList->remove(num);
}
my_fileList->topline(1);
}
// PRIVATE: Don't show hidden files
int Fl_Native_File_Chooser::exist_dialog() {
return(fl_choice("File exists. Are you sure you want to overwrite?",
"Cancel", " OK ", NULL));
}
//
// End of "$Id: Fl_Native_File_Chooser_FLTK.cxx 7015 2010-01-17 17:09:00Z greg.ercolano $".
//

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